Installing all correctly step by step using django-shop tutorial. When i try to make migrations i get an error. Help me fix it please.
(shoptutorial) debserv#debian:~/Desktop/project/django-shop/example$ ./manage.py migrate
Traceback (most recent call last):
File "./manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/home/debserv/Desktop/project/shoptutorial/lib/python3.4/site-packages/django/core/ management/__init__.py", line 354, in execute_from_command_line
utility.execute()
File "/home/debserv/Desktop/project/shoptutorial/lib/python3.4/site-packages/django/core/ management/__init__.py", line 328, in execute
django.setup()
File "/home/debserv/Desktop/project/shoptutorial/lib/python3.4/site-packages/django/__init__.py", line 18, in setup
apps.populate(settings.INSTALLED_APPS)
File "/home/debserv/Desktop/project/shoptutorial/lib/python3.4/site-packages/django/apps/registry.py", line 108, in populate
app_config.import_models(all_models)
File "/home/debserv/Desktop/project/shoptutorial/lib/python3.4/site-packages/django/apps/config.py", line 198, in import_models
self.models_module = import_module(models_module_name)
File "/home/debserv/Desktop/project/shoptutorial/lib/python3.4/importlib/__init__.py", line 109, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 2254, in _gcd_import
File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
File "<frozen importlib._bootstrap>", line 2226, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 1200, in _load_unlocked
File "<frozen importlib._bootstrap>", line 1129, in _exec
File "<frozen importlib._bootstrap>", line 1471, in exec_module
File "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removed
File "/home/debserv/Desktop/project/django-shop/example/myshop/models/__init__.py", line 7, in <module>
from shop.models.defaults.cart import Cart
File "/home/debserv/Desktop/project/django-shop/shop/models/defaults/cart.py", line 5, in <module>
from shop.models.cart import BaseCart
File "/home/debserv/Desktop/project/django-shop/shop/models/cart.py", line 12, in <module>
from shop.money import Money
File "/home/debserv/Desktop/project/django-shop/shop/money/__init__.py", line 2, in <module>
from money_maker import MoneyMaker, AbstractMoney
ImportError: No module named 'money_maker'
I think in your django-shop/shop/money/__init__.py
rather than
from money_maker import MoneyMaker, AbstractMoney
you should either:
import .money_maker import MoneyMaker, AbstractMoney
or
import shop.money.money_maker import MoneyMaker, AbstractMoney
Related
I am trying to run a Django project on my windows machine. I am getting nomodulefounderror. The project consists of multiple settings files for prod, Development, and Test.
I am using a virtual environment, Python 2.7 and Django 1.10 versions
I need help to run this project on my local machine.
Python manage.py runserver --settings=settings_dev_sai
It throws me an error. Here is my error log
python manage.py runserver --settings=bg.settings.settings_dev_sai
Traceback (most recent call last):
File "C:\Users\1\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\core\management\base.py", line 328, in run_from_argv
self.execute(*args, **cmd_options)
File "C:\Users\1\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\core\management\commands\runserver.py", line 60, in execute
super().execute(*args, **options)
File "C:\Users\1\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\core\management\base.py", line 369, in execute
output = self.handle(*args, **options)
File "C:\Users\1\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\core\management\commands\runserver.py", line 67, in handle
if not settings.DEBUG and not settings.ALLOWED_HOSTS:
File "C:\Users\1\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\conf\__init__.py", line 76, in __getattr__
self._setup(name)
File "C:\Users\1\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\conf\__init__.py", line 63, in _setup
self._wrapped = Settings(settings_module)
File "C:\Users\1\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\conf\__init__.py", line 142, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "C:\Users\1\AppData\Local\Programs\Python\Python38-32\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 961, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 783, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "F:\brdge\bridge_sai\bridge\settings.py", line 38, in <module>
from settings_dev_sai import *
ModuleNotFoundError: No module named 'settings_dev_sai'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "C:\Users\1\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\core\management\__init__.py", line 401, in execute_from_command_line
utility.execute()
File "C:\Users\1\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\core\management\__init__.py", line 395, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Users\1\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\core\management\base.py", line 341, in run_from_argv
connections.close_all()
File "C:\Users\1\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\db\utils.py", line 225, in close_all
for alias in self:
File "C:\Users\1\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\db\utils.py", line 219, in __iter__
return iter(self.databases)
File "C:\Users\1\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\utils\functional.py", line 48, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "C:\Users\1\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\db\utils.py", line 153, in databases
self._databases = settings.DATABASES
File "C:\Users\1\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\conf\__init__.py", line 76, in __getattr__
self._setup(name)
File "C:\Users\1\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\conf\__init__.py", line 63, in _setup
self._wrapped = Settings(settings_module)
File "C:\Users\1\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\conf\__init__.py", line 142, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "C:\Users\1\AppData\Local\Programs\Python\Python38-32\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 961, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 783, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "F:\brdge\bridge_sai\bridge\settings.py", line 38, in <module>
from settings_dev_sai import *
ModuleNotFoundError: No module named 'settings_dev_sai'
manage.py File
import os
import sys
if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "bg.settings")
from django.core.management import execute_from_command_line
execute_from_command_line(sys.argv)
Error log Updated
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "F:\brdge\env1\lib\site-packages\django\core\management\__init__.py", line 367, in execute_from_command_line
utility.execute()
File "F:\brdge\env1\lib\site-packages\django\core\management\__init__.py", line 316, in execute
settings.INSTALLED_APPS
File "F:\brdge\env1\lib\site-packages\django\conf\__init__.py", line 53, in __getattr__
self._setup(name)
File "F:\brdge\env1\lib\site-packages\django\conf\__init__.py", line 41, in _setup
self._wrapped = Settings(settings_module)
File "F:\brdge\env1\lib\site-packages\django\conf\__init__.py", line 97, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "C:\Python27\Lib\importlib\__init__.py", line 37, in import_module
__import__(name)
ImportError: No module named settings_dev_sai
i think that you just need run it
python manage.py runserver --settings=bridge.settings_dev_sai
because bridge.settings is a file not a package
It seems your project dir name is 'bg', so I think while importing modules you should do
from bg import settings_dev_sai
or
from bg.settings_dev_sai import *
also make sure settings_dev_sai is in same dir 'bg'
I think i need to answer my question, The problem of nomodulefounderror, due to incomplete data in my Postgres database. I had dumped .sql file into the Postgres database which was given by my manager and later configured the settings file according to the database name and run command python manage.py runserver --settings=bg.settings_dev_sai. It worked perfectly.
I am running this code:
https://github.com/cndreisbach/call-for-service/blob/master/docs/src/development.md
When im running this part of code in my Vagrant shell :
python3 ./cfs/manage.py migrate --settings=cfs.settings.local
It's returning me that there is no "ImportError: No module named 'webapp_credentials'"
This is the error :
Traceback (most recent call last):
File "./cfs/manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/usr/local/lib/python3.5/dist-packages/django/core/management/__init__.py", line 351, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python3.5/dist-packages/django/core/management/__init__.py", line 303, in execute
settings.INSTALLED_APPS
File "/usr/local/lib/python3.5/dist-packages/django/conf/__init__.py", line 48, in __getattr__
self._setup(name)
File "/usr/local/lib/python3.5/dist-packages/django/conf/__init__.py", line 44, in _setup
self._wrapped = Settings(settings_module)
File "/usr/local/lib/python3.5/dist-packages/django/conf/__init__.py", line 92, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "/usr/lib/python3.5/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 985, in _gcd_import
File "<frozen importlib._bootstrap>", line 968, in _find_and_load
File "<frozen importlib._bootstrap>", line 957, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 697, in exec_module
File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
File "/vagrant/cfs/cfs/settings/local.py", line 1, in <module>
from .base import *
File "/vagrant/cfs/cfs/settings/base.py", line 15, in <module>
from webapp_credentials import creds
ImportError: No module named 'webapp_credentials'
Is webapp_credentials a module of python OS how do i fix this?
webapp_credentials.py is on .gitignore, that is why migrate can't find it.
You need this file, which is not versioned in this git repository of your link.
I get an ImportError when trying to import from python standard library.
This only happens when I use a custom django management command and not when I use the normal runserver.
This is the error I get:
Traceback (most recent call last):
File "D:/stack/sendall/website/sendall/manage.py", line 15, in <module>
execute_from_command_line(sys.argv)
File "D:\stack\sendall\website\venv\lib\site-packages\django\core\management\__init__.py", line 381, in execute_from_command_line
utility.execute()
File "D:\stack\sendall\website\venv\lib\site-packages\django\core\management\__init__.py", line 357, in execute
django.setup()
File "D:\stack\sendall\website\venv\lib\site-packages\django\__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "D:\stack\sendall\website\venv\lib\site-packages\django\apps\registry.py", line 112, in populate
app_config.import_models()
File "D:\stack\sendall\website\venv\lib\site-packages\django\apps\config.py", line 198, in import_models
self.models_module = import_module(models_module_name)
File "C:\Users\Joseph\AppData\Local\Programs\Python\Python36-32\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 978, in _gcd_import
File "<frozen importlib._bootstrap>", line 961, in _find_and_load
File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 655, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed
File "D:\stack\sendall\website\sendall\accounts\models.py", line 1, in <module>
from typing import AsyncContextManager
ImportError: cannot import name 'AsyncContextManager'
I am using python 3.7
Hope someone can help me solve this issue
I'm using some enum fields in my data model. I've installed django-enumfield package. My django version is 1.10.6 and django-enumfield version is 1.2.1.
Anyway I get the following error when db migration is issued.
$ python manage.py makemigrations
Output:
Traceback (most recent call last):
File "manage.py", line 22, in <module>
execute_from_command_line(sys.argv)
File "/usr/local/lib/python3.5/dist-packages/Django-1.10.6-py3.5.egg/django/core/management/__init__.py", line 367, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python3.5/dist-packages/Django-1.10.6-py3.5.egg/django/core/management/__init__.py", line 341, in execute
django.setup()
File "/usr/local/lib/python3.5/dist-packages/Django-1.10.6-py3.5.egg/django/__init__.py", line 27, in setup
apps.populate(settings.INSTALLED_APPS)
File "/usr/local/lib/python3.5/dist-packages/Django-1.10.6-py3.5.egg/django/apps/registry.py", line 108, in populate
app_config.import_models(all_models)
File "/usr/local/lib/python3.5/dist-packages/Django-1.10.6-py3.5.egg/django/apps/config.py", line 199, in import_models
self.models_module = import_module(models_module_name)
File "/home/indikau/anaconda3/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 978, in _gcd_import
File "<frozen importlib._bootstrap>", line 961, in _find_and_load
File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 655, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed
File "/home/indikau/workspace/hotel_manager/manager/models.py", line 4, in <module>
from django_enumfield import enum
File "/usr/local/lib/python3.5/dist-packages/django_enumfield/enum.py", line 6, in <module>
from django_enumfield.db.fields import EnumField
File "/usr/local/lib/python3.5/dist-packages/django_enumfield/db/fields.py", line 8, in <module>
class EnumField(six.with_metaclass(models.SubfieldBase, models.IntegerField)):
AttributeError: module 'django.db.models' has no attribute 'SubfieldBase'
Is there anyway to fix this problem?
Thanks.
SubfieldBase was deprecated since 1.8 and it's removed in 1.10.
There looks like a few solutions available here: https://github.com/5monkeys/django-enumfield/issues/39
after starting clean project bases on these packages (basically my requirements.txt):
Django>=1.7, <1.8
psycopg2
aldjemy
My python manage.py migrate raise errors:
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/Users/stay-wide-awake/web/bank/env/lib/python3.4/site-packages/django/core/management/__init__.py", line 385, in execute_from_command_line
utility.execute()
File "/Users/stay-wide-awake/web/bank/env/lib/python3.4/site-packages/django/core/management/__init__.py", line 354, in execute
django.setup()
File "/Users/stay-wide-awake/web/bank/env/lib/python3.4/site-packages/django/__init__.py", line 21, in setup
apps.populate(settings.INSTALLED_APPS)
File "/Users/stay-wide-awake/web/bank/env/lib/python3.4/site-packages/django/apps/registry.py", line 108, in populate
app_config.import_models(all_models)
File "/Users/stay-wide-awake/web/bank/env/lib/python3.4/site-packages/django/apps/config.py", line 202, in import_models
self.models_module = import_module(models_module_name)
File "/Users/stay-wide-awake/web/bank/env/lib/python3.4/importlib/__init__.py", line 109, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 2254, in _gcd_import
File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
File "<frozen importlib._bootstrap>", line 2226, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 1200, in _load_unlocked
File "/Users/stay-wide-awake/web/bank/env/lib/python3.4/site-packages/aldjemy/models.py", line 2, in <module>
from .orm import prepare_models
File "/Users/stay-wide-awake/web/bank/env/lib/python3.4/site-packages/aldjemy/orm.py", line 7, in <module>
from .core import get_tables, get_engine, Cache
File "/Users/stay-wide-awake/web/bank/env/lib/python3.4/site-packages/aldjemy/core.py", line 6, in <module>
from .table import generate_tables
File "/Users/stay-wide-awake/web/bank/env/lib/python3.4/site-packages/aldjemy/table.py", line 4, in <module>
from django.db.models.loading import AppCache
ImportError: cannot import name 'AppCache'
(env)3-AM-OSX:bank stay-wide-awake$ python manage.py makemigrations accounts
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/Users/stay-wide-awake/web/bank/env/lib/python3.4/site-packages/django/core/management/__init__.py", line 385, in execute_from_command_line
utility.execute()
File "/Users/stay-wide-awake/web/bank/env/lib/python3.4/site-packages/django/core/management/__init__.py", line 354, in execute
django.setup()
File "/Users/stay-wide-awake/web/bank/env/lib/python3.4/site-packages/django/__init__.py", line 21, in setup
apps.populate(settings.INSTALLED_APPS)
File "/Users/stay-wide-awake/web/bank/env/lib/python3.4/site-packages/django/apps/registry.py", line 108, in populate
app_config.import_models(all_models)
File "/Users/stay-wide-awake/web/bank/env/lib/python3.4/site-packages/django/apps/config.py", line 202, in import_models
self.models_module = import_module(models_module_name)
File "/Users/stay-wide-awake/web/bank/env/lib/python3.4/importlib/__init__.py", line 109, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 2254, in _gcd_import
File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
File "<frozen importlib._bootstrap>", line 2226, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 1200, in _load_unlocked
File "<frozen importlib._bootstrap>", line 1129, in _exec
File "<frozen importlib._bootstrap>", line 1471, in exec_module
File "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removed
File "/Users/stay-wide-awake/web/bank/env/lib/python3.4/site-packages/aldjemy/models.py", line 2, in <module>
from .orm import prepare_models
File "/Users/stay-wide-awake/web/bank/env/lib/python3.4/site-packages/aldjemy/orm.py", line 7, in <module>
from .core import get_tables, get_engine, Cache
File "/Users/stay-wide-awake/web/bank/env/lib/python3.4/site-packages/aldjemy/core.py", line 6, in <module>
from .table import generate_tables
File "/Users/stay-wide-awake/web/bank/env/lib/python3.4/site-packages/aldjemy/table.py", line 4, in <module>
from django.db.models.loading import AppCache
ImportError: cannot import name 'AppCache'
It doesn't matter what database i use in my configuration - postgresql or sqlite, so i figure out that SQLAlchemy is causing extension. But I cant figure out where is the problem spot. Can you help?
Also i use Python3.4, as u can see from logs.
Installing directly from repository helps!