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 accidentally pulled an old git repo of my Django build ( It's running on a Heroku dyno ) and it had overwritten my entire local build, I managed to restore it back to the latest git repo which was previously working on my local build ( but not my Heroku dyno ) and the server now won't run locally or on my live build?
Error from the shell:
python manage.py runserver
File "manage.py", line 22, in <module>
execute_from_command_line(sys.argv)
File "/home/johnnie/.local/lib/python3.7/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line
utility.execute()
File "/home/johnnie/.local/lib/python3.7/site-packages/django/core/management/__init__.py", line 345, in execute
settings.INSTALLED_APPS
File "/home/johnnie/.local/lib/python3.7/site-packages/django/conf/__init__.py", line 76, in __getattr__
self._setup(name)
File "/home/johnnie/.local/lib/python3.7/site-packages/django/conf/__init__.py", line 63, in _setup
self._wrapped = Settings(settings_module)
File "/home/johnnie/.local/lib/python3.7/site-packages/django/conf/__init__.py", line 142, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "/usr/lib/python3.7/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/home/johnnie/myproject/myproject/mysite/mysite/settings.py", line 141, in <module>
del DATABASES['default']['OPTIONS']['sslmode']
KeyError: 'OPTIONS'
edit:
del DATABASES['default']['OPTIONS']['sslmode']
was a section added by Heroku when committed by git.
removed this plus other Heroku changes which resolved issues.
I made a website with django and I use celery for asynchronous task, when I run:
./manage.py runserver
I got the error:
Traceback (most recent call last):
File "./manage.py", line 22, in <module>
execute_from_command_line(sys.argv)
File "/home/rouizi/OC_project13/venv/lib/python3.6/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line
utility.execute()
File "/home/rouizi/OC_project13/venv/lib/python3.6/site-packages/django/core/management/__init__.py", line 395, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/rouizi/OC_project13/venv/lib/python3.6/site-packages/django/core/management/base.py", line 341, in run_from_argv
connections.close_all()
File "/home/rouizi/OC_project13/venv/lib/python3.6/site-packages/django/db/utils.py", line 225, in close_all
for alias in self:
File "/home/rouizi/OC_project13/venv/lib/python3.6/site-packages/django/db/utils.py", line 219, in __iter__
return iter(self.databases)
File "/home/rouizi/OC_project13/venv/lib/python3.6/site-packages/django/utils/functional.py", line 48, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/home/rouizi/OC_project13/venv/lib/python3.6/site-packages/django/db/utils.py", line 153, in databases
self._databases = settings.DATABASES
File "/home/rouizi/OC_project13/venv/lib/python3.6/site-packages/django/conf/__init__.py", line 76, in __getattr__
self._setup(name)
File "/home/rouizi/OC_project13/venv/lib/python3.6/site-packages/django/conf/__init__.py", line 63, in _setup
self._wrapped = Settings(settings_module)
File "/home/rouizi/OC_project13/venv/lib/python3.6/site-packages/django/conf/__init__.py", line 142, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "/usr/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 941, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/home/rouizi/OC_project13/car_rental/__init__.py", line 5, in <module>
from .celery import app as celery_app
File "/home/rouizi/OC_project13/car_rental/celery.py", line 3, in <module>
from celery import Celery
File "/home/rouizi/OC_project13/venv/lib/python3.6/site-packages/celery/local.py", line 509, in __getattr__
module = __import__(self._object_origins[name], None, None, [name])
File "/home/rouizi/OC_project13/venv/lib/python3.6/site-packages/celery/app/__init__.py", line 5, in <module>
from celery import _state
File "/home/rouizi/OC_project13/venv/lib/python3.6/site-packages/celery/_state.py", line 17, in <module>
from celery.utils.threads import LocalStack
File "/home/rouizi/OC_project13/venv/lib/python3.6/site-packages/celery/utils/__init__.py", line 9, in <module>
from kombu.utils.objects import cached_property
ModuleNotFoundError: No module named 'kombu'
I tried to install kombu:
pip install kombu
Collecting kombu
Using cached https://files.pythonhosted.org/packages/34/7e/44445f7d9031e82b4a1160141de35ca810f44041bf5065b45c68ab0ec9e8/kombu-4.6.8-py2.py3-none-any.whl
Requirement already satisfied: amqp<2.6,>=2.5.2 in ./venv/lib/python3.6/site-packages (from kombu)
Requirement already satisfied: importlib-metadata>=0.18; python_version < "3.8" in ./venv/lib/python3.6/site-packages (from kombu)
Requirement already satisfied: vine<5.0.0a1,>=1.1.3 in ./venv/lib/python3.6/site-packages (from amqp<2.6,>=2.5.2->kombu)
Requirement already satisfied: zipp>=0.5 in ./venv/lib/python3.6/site-packages (from importlib-metadata>=0.18; python_version < "3.8"->kombu)
Installing collected packages: kombu
Successfully installed kombu-4.6.8
And now I get this error if a run the server:
Watching for file changes with StatReloader
Exception in thread django-main-thread:
Traceback (most recent call last):
File "/home/rouizi/OC_project13/venv/lib/python3.6/site-packages/django/apps/config.py", line 118, in create
cls = getattr(mod, cls_name)
AttributeError: module 'kombu.transport' has no attribute 'django'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3.6/threading.py", line 916, in _bootstrap_inner
self.run()
File "/usr/lib/python3.6/threading.py", line 864, in run
self._target(*self._args, **self._kwargs)
File "/home/rouizi/OC_project13/venv/lib/python3.6/site-packages/django/utils/autoreload.py", line 53, in wrapper
fn(*args, **kwargs)
File "/home/rouizi/OC_project13/venv/lib/python3.6/site-packages/django/core/management/commands/runserver.py", line 109, in inner_run
autoreload.raise_last_exception()
File "/home/rouizi/OC_project13/venv/lib/python3.6/site-packages/django/utils/autoreload.py", line 76, in raise_last_exception
raise _exception[1]
File "/home/rouizi/OC_project13/venv/lib/python3.6/site-packages/django/core/management/__init__.py", line 357, in execute
autoreload.check_errors(django.setup)()
File "/home/rouizi/OC_project13/venv/lib/python3.6/site-packages/django/utils/autoreload.py", line 53, in wrapper
fn(*args, **kwargs)
File "/home/rouizi/OC_project13/venv/lib/python3.6/site-packages/django/__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "/home/rouizi/OC_project13/venv/lib/python3.6/site-packages/django/apps/registry.py", line 91, in populate
app_config = AppConfig.create(entry)
File "/home/rouizi/OC_project13/venv/lib/python3.6/site-packages/django/apps/config.py", line 136, in create
import_module(entry)
File "/usr/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'kombu.transport.django'
I know that the django module was definitely removed from the kombu package but if I remove kombu I get the first error, how can I fix this ?
I am using django==3.0.3, celery==4.4.1, kombu==4.6.8
You use
celery 4.4.1 has requirement kombu<4.7,>=4.6.10, but you'll have kombu 4.6.8 which is incompatible.
Please use:
pip install celery==4.4.6
pip install kombu==4.6.10
and if you want to redis you should this version
pip install redis==3.2.1
Then you to terminal and type python
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 have started working on python/django. But while using settings.py for database connection, I am getting the following error. I am using pycharm in windows 8.
"C:\Program Files (x86)\JetBrains\PyCharm 4.0.6\bin\runnerw.exe" C:\Python34\python.exe "C:/Users/hp user/PycharmProjects/edu/manage.py" runserver 8000
Traceback (most recent call last):
File "C:\Python34\lib\site-packages\django\db\backends\mysql\base.py", line 24, in <module>
import MySQLdb as Database
ImportError: No module named 'MySQLdb'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:/Users/hp user/PycharmProjects/edu/manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "C:\Python34\lib\site-packages\django\core\management\__init__.py", line 338, in execute_from_command_line
utility.execute()
File "C:\Python34\lib\site-packages\django\core\management\__init__.py", line 312, in execute
django.setup()
File "C:\Python34\lib\site-packages\django\__init__.py", line 18, in setup
apps.populate(settings.INSTALLED_APPS)
File "C:\Python34\lib\site-packages\django\apps\registry.py", line 108, in populate
app_config.import_models(all_models)
File "C:\Python34\lib\site-packages\django\apps\config.py", line 198, in import_models
self.models_module = import_module(models_module_name)
File "C:\Python34\lib\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 "C:\Python34\lib\site-packages\django\contrib\auth\models.py", line 41, in <module>
class Permission(models.Model):
File "C:\Python34\lib\site-packages\django\db\models\base.py", line 139, in __new__
new_class.add_to_class('_meta', Options(meta, **kwargs))
File "C:\Python34\lib\site-packages\django\db\models\base.py", line 324, in add_to_class
value.contribute_to_class(cls, name)
File "C:\Python34\lib\site-packages\django\db\models\options.py", line 250, in contribute_to_class
self.db_table = truncate_name(self.db_table, connection.ops.max_name_length())
File "C:\Python34\lib\site-packages\django\db\__init__.py", line 36, in __getattr__
return getattr(connections[DEFAULT_DB_ALIAS], item)
File "C:\Python34\lib\site-packages\django\db\utils.py", line 240, in __getitem__
backend = load_backend(db['ENGINE'])
File "C:\Python34\lib\site-packages\django\db\utils.py", line 111, in load_backend
return import_module('%s.base' % backend_name)
File "C:\Python34\lib\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 "C:\Python34\lib\site-packages\django\db\backends\mysql\base.py", line 27, in <module>
raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e)
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No module named 'MySQLdb'
Process finished with exit code 1
Try installing the missing module with:
pip install mysql-python
(you might require sudo).
The author used windows 8 and Python 3.4. mysql-python is not compatible with Python 3.x. Please use mysqlclient
pip install mysqlclient