I am working on a Django project and trying to run the command coverage run --source='.' manage.py test myapp from the Django documentation. Somehow coverage uses a different python path than the virtual environment I am in (I guess that is the reason that the module is not found)
I get the following output:
(venv) username in ~/project on branch basket > coverage run --source='.' manage.py test myapp
Traceback (most recent call last):
File "manage.py", line 22, in <module>
main()
File "manage.py", line 18, in main
execute_from_command_line(sys.argv)
File "/Users/username/.pyenv/versions/3.7.2/lib/python3.7/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line
utility.execute()
File "/Users/username/.pyenv/versions/3.7.2/lib/python3.7/site-packages/django/core/management/__init__.py", line 395, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Users/username/.pyenv/versions/3.7.2/lib/python3.7/site-packages/django/core/management/commands/test.py", line 23, in run_from_argv
super().run_from_argv(argv)
File "/Users/username/.pyenv/versions/3.7.2/lib/python3.7/site-packages/django/core/management/base.py", line 322, in run_from_argv
parser = self.create_parser(argv[0], argv[1])
File "/Users/username/.pyenv/versions/3.7.2/lib/python3.7/site-packages/django/core/management/base.py", line 296, in create_parser
self.add_arguments(parser)
File "/Users/username/.pyenv/versions/3.7.2/lib/python3.7/site-packages/django/core/management/commands/test.py", line 44, in add_arguments
test_runner_class = get_runner(settings, self.test_runner)
File "/Users/username/.pyenv/versions/3.7.2/lib/python3.7/site-packages/django/test/utils.py", line 302, in get_runner
test_runner_class = test_runner_class or settings.TEST_RUNNER
File "/Users/username/.pyenv/versions/3.7.2/lib/python3.7/site-packages/django/conf/__init__.py", line 83, in __getattr__
self._setup(name)
File "/Users/username/.pyenv/versions/3.7.2/lib/python3.7/site-packages/django/conf/__init__.py", line 70, in _setup
self._wrapped = Settings(settings_module)
File "/Users/username/.pyenv/versions/3.7.2/lib/python3.7/site-packages/django/conf/__init__.py", line 177, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "/Users/username/.pyenv/versions/3.7.2/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 "/Users/username/project/config/settings.py", line 14, in <module>
from decouple import config, Csv
ModuleNotFoundError: No module named 'decouple'
I am using venv from the regular python installation and checked my venv by importing a non-existent module in my settings.py:
from testmodule import test, which gives me the following output for the command python manage.py runserver
(venv) username in ~/project > python manage.py runserver
Traceback (most recent call last):
File "/Users/username/project/venv/lib/python3.9/site-packages/django/core/management/base.py", line 354, in run_from_argv
self.execute(*args, **cmd_options)
File "/Users/username/project/venv/lib/python3.9/site-packages/django/core/management/commands/runserver.py", line 61, in execute
super().execute(*args, **options)
File "/Users/username/project/venv/lib/python3.9/site-packages/django/core/management/base.py", line 398, in execute
output = self.handle(*args, **options)
File "/Users/username/project/venv/lib/python3.9/site-packages/django/core/management/commands/runserver.py", line 68, in handle
if not settings.DEBUG and not settings.ALLOWED_HOSTS:
File "/Users/username/project/venv/lib/python3.9/site-packages/django/conf/__init__.py", line 82, in __getattr__
self._setup(name)
File "/Users/username/project/venv/lib/python3.9/site-packages/django/conf/__init__.py", line 69, in _setup
self._wrapped = Settings(settings_module)
File "/Users/username/project/venv/lib/python3.9/site-packages/django/conf/__init__.py", line 170, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 850, in exec_module
File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
File "/Users/username/project/config/settings.py", line 16, in <module>
from testmodule import test
ModuleNotFoundError: No module named 'testmodule'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/username/project/manage.py", line 22, in <module>
main()
File "/Users/username/project/manage.py", line 18, in main
execute_from_command_line(sys.argv)
File "/Users/username/project/venv/lib/python3.9/site-packages/django/core/management/__init__.py", line 419, in execute_from_command_line
utility.execute()
File "/Users/username/project/venv/lib/python3.9/site-packages/django/core/management/__init__.py", line 413, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Users/username/project/venv/lib/python3.9/site-packages/django/core/management/base.py", line 367, in run_from_argv
connections.close_all()
File "/Users/username/project/venv/lib/python3.9/site-packages/django/db/utils.py", line 208, in close_all
for alias in self:
File "/Users/username/project/venv/lib/python3.9/site-packages/django/utils/connection.py", line 73, in __iter__
return iter(self.settings)
File "/Users/username/project/venv/lib/python3.9/site-packages/django/utils/functional.py", line 48, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/Users/username/project/venv/lib/python3.9/site-packages/django/utils/connection.py", line 45, in settings
self._settings = self.configure_settings(self._settings)
File "/Users/username/project/venv/lib/python3.9/site-packages/django/db/utils.py", line 144, in configure_settings
databases = super().configure_settings(databases)
File "/Users/username/project/venv/lib/python3.9/site-packages/django/utils/connection.py", line 50, in configure_settings
settings = getattr(django_settings, self.settings_name)
File "/Users/username/project/venv/lib/python3.9/site-packages/django/conf/__init__.py", line 82, in __getattr__
self._setup(name)
File "/Users/username/project/venv/lib/python3.9/site-packages/django/conf/__init__.py", line 69, in _setup
self._wrapped = Settings(settings_module)
File "/Users/username/project/venv/lib/python3.9/site-packages/django/conf/__init__.py", line 170, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 850, in exec_module
File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
File "/Users/username/project/config/settings.py", line 16, in <module>
from testmodule import test
ModuleNotFoundError: No module named 'testmodule'
To me the problem doesn't seem related to django or the python-decouple module, but coverage not using the python path of my sourced venv. I tried to search the docs from coverage but couldn't identify what function or method is used when running coverage run can somebody help me out on where to look or how to identify the problem?
This seems to be a conflict with your global python packages.
As your log suggests, coverage is from /Users/username/.pyenv/versions/3.7.2/.
And you want to use the /Users/username/project/venv/lib/python3.9/.
There are 2 ways to do this, uninstall global coverage.
(venv) $ deactivate
$ pip3 uninstall coverage
$ source venv/bin/activate
(venv) $ python -m pip install coverage
Or if you plan on keeping global package you can try this.
(venv) $ python -m pip install coverage
(venv) $ python -m coverage
This will get the packages with respect to /Users/username/project/venv/lib/python3.9/
Related
I´m having a problem running my old django project. Its giving an error after i run py manage.py.
I tryed to use the command py manage.py makemigrations
Traceback (most recent call last):File "C:\Users\ricardo martins\Downloads\LES-fosquito\LES-fosquito\manage.py", line 15, in <module>
execute_from_command_line(sys.argv)
File "C:\Users\ricardo martins\AppData\Local\Programs\Python\Python310\lib\site-packages\django\core\management\__init__.py", line 446, in execute_from_command_line
utility.execute()
File "C:\Users\ricardo martins\AppData\Local\Programs\Python\Python310\lib\site-packages\django\core\management\__init__.py", line 420, in execute
django.setup()
File "C:\Users\ricardo martins\AppData\Local\Programs\Python\Python310\lib\site-packages\django\__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "C:\Users\ricardo martins\AppData\Local\Programs\Python\Python310\lib\site-packages\django\apps\registry.py", line 124, in populate
app_config.ready()
File "C:\Users\ricardo martins\AppData\Local\Programs\Python\Python310\lib\site-packages\django\contrib\admin\apps.py", line 27, in ready
self.module.autodiscover()
File "C:\Users\ricardo martins\AppData\Local\Programs\Python\Python310\lib\site-packages\django\contrib\admin\__init__.py", line 50, in autodiscover
autodiscover_modules("admin", register_to=site)
File "C:\Users\ricardo martins\AppData\Local\Programs\Python\Python310\lib\site-packages\django\utils\module_loading.py", line 58, in autodiscover_modules
import_module("%s.%s" % (app_config.name, module_to_search))
File "C:\Users\ricardo martins\AppData\Local\Programs\Python\Python310\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 883, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "C:\Users\ricardo martins\Downloads\LES-fosquito\LES-fosquito\processes\admin.py", line 4, in <module>
from tinymce.widgets import TinyMCE
ModuleNotFoundError: No module named 'tinymce'
Are you using the TinyMCE library in your code? If you are trying to run it locally, try to see if you have the correct dependencies installed, and if it is not needed you can simply remove the import statemnt.
I've been using Django for just over a year for the development of an automation software and am currently just running the project locally on my windows machine.
I hadn't run into any issues with it, until I tried running cron tasks, which ofc windows doesn't support. Scheduled tasks don't work the same way imo, so I installed a Ubuntu VM to work with the project.
Set everything up correctly(I think?), installed Django and all. Currently installing all the libraries the project uses, one of which is django-money. I have installed it, as well as py-moneyed, yet on trying to make migrations, or run the server, I run into this error
enter image description here
Can't find anything about this online. The project still works perfectly with the windows command prompt, as well as PowerShell but having this issue on the ubuntu VM.
Installed apps on my settings.py look like:
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'bootstrap5',
'sass_processor',
'djmoney',
'background_task',
'django_crontab',
'companies',
'google_cal',
'dashboard',
]
Any help on this, or good alternative for corn tasks-need some to run every 2 hours and update the db and others to run once a day at a specific time. Celery also does not work with Windows.
The full error is:
Traceback (most recent call last):
File "/mnt/f/Django/RC/Sales-automation/sales-automation/ubuntu_venv
/lib/python3.8/site-packages/django/core/management/base.py", line 354, in run_from_argv self.execute(*args, **cmd_options)
File "/mnt/f/Django/RC/Sales-automation/sales-automation/ubuntu_venv/lib/python3.8/site-packages/django/core/management/commands/runserver.py", line 61, in execute super().execute(*args, **options)
File "/mnt/f/Django/RC/Sales-automation/sales-automation/ubuntu_venv/lib/python3.8/site-packages/django/core/management/base.py", line 398, in execute output = self.handle(*args, **options)
File "/mnt/f/Django/RC/Sales-automation/sales-automation/ubuntu_venv/lib/python3.8/site-packages/django/core/management/commands/runserver.py", line 68, in handle if not settings.DEBUG and not settings.ALLOWED_HOSTS:
File "/mnt/f/Django/RC/Sales-automation/sales-automation/ubuntu_venv/lib/python3.8/site-packages/django/conf/__init__.py", line 82, in __getattr__ self._setup(name)
File "/mnt/f/Django/RC/Sales-automation/sales-automation/ubuntu_venv/lib/python3.8/site-packages/django/conf/__init__.py", line 69, in _setup self._wrapped = Settings(settings_module)
File "/mnt/f/Django/RC/Sales-automation/sales-automation/ubuntu_venv/lib/python3.8/site-packages/django/conf/__init__.py", line 170, in __init__ mod =
importlib.import_module(self.SETTINGS_MODULE)
File "/usr/lib/python3.8/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 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 848, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/mnt/f/Django/RC/Sales-automation/sales-automation/automation_software/automation_software/settings.py", line 16, in <module>
from djmoney.settings import FIXER_ACCESS_KEY
File "/mnt/f/Django/RC/Sales-automation/sales-automation/ubuntu_venv/lib/python3.8/site-packages/djmoney/settings.py", line 6, in <module>
from moneyed import CURRENCIES, DEFAULT_CURRENCY, DEFAULT_CURRENCY_CODE
ImportError: cannot import name 'DEFAULT_CURRENCY' from 'moneyed' (/mnt/f/Django/RC/Sales-automation/sales-automation/ubuntu_venv/lib/python3.8/site-packages/moneyed/__init__.py)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "manage.py", line 22, in <module> main()
File "manage.py", line 18, in main execute_from_command_line(sys.argv)
File "/mnt/f/Django/RC/Sales-automation/sales-automation/ubuntu_venv/lib/python3.8/site-packages/django/core/management/__init__.py", line 419, in execute_from_command_line utility.execute()
File "/mnt/f/Django/RC/Sales-automation/sales-automation/ubuntu_venv/lib/python3.8/site-packages/django/core/management/__init__.py", line 413, in execute self.fetch_command(subcommand).run_from_argv(self.argv)
File "/mnt/f/Django/RC/Sales-automation/sales-automation/ubuntu_venv/lib/python3.8/site-packages/django/core/management/base.py", line 367, in run_from_argv connections.close_all()
File "/mnt/f/Django/RC/Sales-automation/sales-automation/ubuntu_venv/lib/python3.8/site-packages/django/db/utils.py", line 208, in close_all for alias in self:
File "/mnt/f/Django/RC/Sales-automation/sales-automation/ubuntu_venv/lib/python3.8/site-packages/django/utils/connection.py", line 73, in __iter__ return
iter(self.settings)
File "/mnt/f/Django/RC/Sales-automation/sales-automation/ubuntu_venv/lib/python3.8/site-packages/django/utils/functional.py", line 48, in __get__ res = instance.__dict__[self.name] = self.func(instance)
File "/mnt/f/Django/RC/Sales-automation/sales-automation/ubuntu_venv/lib/python3.8/site-packages/django/utils/connection.py", line 45, in
settings self._settings =
self.configure_settings(self._settings)
File "/mnt/f/Django/RC/Sales-automation/sales-automation/ubuntu_venv/lib/python3.8/site-packages/django/db/utils.py", line 144, in configure_settings databases =
super().configure_settings(databases)
File "/mnt/f/Django/RC/Sales-automation/sales-automation/ubuntu_venv/lib/python3.8/site-packages/django/utils/connection.py", line 50, in configure_settings settings = getattr(django_settings, self.settings_name)
File "/mnt/f/Django/RC/Sales-automation/sales-automation/ubuntu_venv/lib/python3.8/site-packages/django/conf/__init__.py", line 82, in __getattr__ self._setup(name)
File "/mnt/f/Django/RC/Sales-automation/sales-automation/ubuntu_venv/lib/python3.8/site-packages/django/conf/__init__.py", line 69, in _setup self._wrapped = Settings(settings_module)
File "/mnt/f/Django/RC/Sales-automation/sales-automation/ubuntu_venv/lib/python3.8/site-packages/django/conf/__init__.py", line 170, in __init__ mod = importlib.import_module(self.SETTINGS_MODULE)
File "/usr/lib/python3.8/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 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 848, in exec_module
File "<frozen importlib._bootstrap>", line 219, in
_call_with_frames_removed
File "/mnt/f/Django/RC/Sales-automation/sales-automation/automation_software/automation_software/settings.py", line 16, in <module>
from djmoney.settings import FIXER_ACCESS_KEY
File "/mnt/f/Django/RC/Sales-automation/sales-automation/ubuntu_venv/lib/python3.8/site-packages/djmoney/settings.py", line 6, in <module>
from moneyed import CURRENCIES, DEFAULT_CURRENCY, DEFAULT_CURRENCY_CODE
ImportError: cannot import name 'DEFAULT_CURRENCY' from 'moneyed' (/mnt/f/Django/RC/Sales-automation/sales-automation/ubuntu_venv/lib/python3.8/site-packages/moneyed/__init__.py)
That constant has been removed in version 2.0. See this link https://github.com/py-moneyed/py-moneyed/blob/ef5d65da3e6e774a377b6e1434a051f0454d2193/CHANGES.rst
So I'm trying to run my development server using the command "python manage.py runserver"
But whenever I try to run it, it gives me this error;
Watching for file changes with StatReloader
Exception in thread Thread-1:
Traceback (most recent call last):
File "C:\Users\Kasutaja\AppData\Local\Programs\Python\Python36-32\lib\threading.py", line 916, in _bootstrap_inner
self.run()
File "C:\Users\Kasutaja\AppData\Local\Programs\Python\Python36-32\lib\threading.py", line 864, in run
self._target(*self._args, **self._kwargs)
File "C:\Users\Kasutaja\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\utils\autoreload.py", line 54, in wrapper
fn(*args, **kwargs)
File "C:\Users\Kasutaja\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\commands\runserver.py", line 109, in inner_run
autoreload.raise_last_exception()
File "C:\Users\Kasutaja\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\utils\autoreload.py", line 77, in raise_last_exception
raise _exception[0](_exception[1]).with_traceback(_exception[2])
File "C:\Users\Kasutaja\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\utils\autoreload.py", line 54, in wrapper
fn(*args, **kwargs)
File "C:\Users\Kasutaja\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "C:\Users\Kasutaja\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\apps\registry.py", line 91, in populate
app_config = AppConfig.create(entry)
File "C:\Users\Kasutaja\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\apps\config.py", line 90, in create
module = import_module(entry)
File "C:\Users\Kasutaja\AppData\Local\Programs\Python\Python36-32\lib\importlib\__init__.py", line 125, 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 948, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'django_countries'
Traceback (most recent call last):
File "C:\Users\Kasutaja\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\apps\registry.py", line 155, in get_app_config
return self.app_configs[app_label]
KeyError: 'admin'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "manage.py", line 15, in <module>
execute_from_command_line(sys.argv)
File "C:\Users\Kasutaja\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\__init__.py", line 381, in execute_from_command_line
utility.execute()
File "C:\Users\Kasutaja\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\__init__.py", line 375, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Users\Kasutaja\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\base.py", line 323, in run_from_argv
self.execute(*args, **cmd_options)
File "C:\Users\Kasutaja\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\commands\runserver.py", line 60, in execute
super().execute(*args, **options)
File "C:\Users\Kasutaja\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\base.py", line 364, in execute
output = self.handle(*args, **options)
File "C:\Users\Kasutaja\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\commands\runserver.py", line 95, in handle
self.run(**options)
File "C:\Users\Kasutaja\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\commands\runserver.py", line 102, in run
autoreload.run_with_reloader(self.inner_run, **options)
File "C:\Users\Kasutaja\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\utils\autoreload.py", line 579, in run_with_reloader
start_django(reloader, main_func, *args, **kwargs)
File "C:\Users\Kasutaja\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\utils\autoreload.py", line 564, in start_django
reloader.run(django_main_thread)
File "C:\Users\Kasutaja\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\utils\autoreload.py", line 272, in run
get_resolver().urlconf_module
File "C:\Users\Kasutaja\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\utils\functional.py", line 80, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "C:\Users\Kasutaja\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\urls\resolvers.py", line 564, in urlconf_module
return import_module(self.urlconf_name)
File "C:\Users\Kasutaja\AppData\Local\Programs\Python\Python36-32\lib\importlib\__init__.py", line 125, 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 "F:\Users\Kasutaja\Documents\Veebipood v4\django-ecommerce\djecommerce\urls.py",
line 6, in <module>
path('admin/', admin.site.urls),
File "C:\Users\Kasutaja\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\utils\functional.py", line 256, in inner
self._setup()
File "C:\Users\Kasutaja\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\contrib\admin\sites.py", line 529, in _setup
AdminSiteClass = import_string(apps.get_app_config('admin').default_site)
File "C:\Users\Kasutaja\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\apps\registry.py", line 162, in get_app_config
raise LookupError(message)
LookupError: No installed app with label 'admin'.
I have tried searching for solutions to this problem but nothing seems to be working. There seems to also be a weird issue with django-countries. Whenever I try installing it, it says;
Collecting django-countries
Using cached django-countries-6.0.tar.gz (617 kB)
WARNING: Generating metadata for package django-countries produced metadata for project name unknown. Fix your #egg=django-countries fragments.
Requirement already satisfied (use --upgrade to upgrade): unknown from https://files.pythonhosted.org/packages/6d/7a/4046a82f6f0c7d00ad24b3a4fc30d10c562949bb6cd40ef7f3051ed7e2bc/django-countries-6.0.tar.gz#sha256=cca351f304d18187b6200e1aae381c2902045c33aea5f4da58fd74685b7cd4fc in c:\users\kasutaja\appdata\local\programs\python\python36-32\lib\site-packages
The weird thing with this is, that whenever I try to run "python manage.py makemigrations", it says;
Traceback (most recent call last):
File "manage.py", line 15, in <module>
execute_from_command_line(sys.argv)
File "C:\Users\Kasutaja\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\__init__.py", line 381, in execute_from_command_line
utility.execute()
File "C:\Users\Kasutaja\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\__init__.py", line 357, in execute
django.setup()
File "C:\Users\Kasutaja\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "C:\Users\Kasutaja\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\apps\registry.py", line 91, in populate
app_config = AppConfig.create(entry)
File "C:\Users\Kasutaja\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\apps\config.py", line 90, in create
module = import_module(entry)
File "C:\Users\Kasutaja\AppData\Local\Programs\Python\Python36-32\lib\importlib\__init__.py", line 125, 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 948, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'django_countries'
Does anyone know how to fix this?
Thanks in advance,
Nimetu.
Ok, figured it out. Just putting this out there just incase anyone has the same issue. If your project has a requirements.txt file (if it doesn't make one) and add (If you want to use django-countries)
django-countries==5.3.3
To it, you can also use the latest version but I chose to use version 5.3.3 in this case. After that run the command
pip install -r requirements.txt
I have problem with migrating my database on Heroku trying to run heroku run python manage.py migrate. I always get this error:
(venv) E:\Studia\advise\promotion>heroku run python manage.py migrate
Running python manage.py migrate on ⬢ pro-motion... up, run.6349 (Free)
Traceback (most recent call last):
File "manage.py", line 15, in <module>
execute_from_command_line(sys.argv)
File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
utility.execute()
File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/__init__.py", line 325, in execute
settings.INSTALLED_APPS
File "/app/.heroku/python/lib/python3.6/site-packages/django/conf/__init__.py", line 79, in __getattr__
self._setup(name)
File "/app/.heroku/python/lib/python3.6/site-packages/django/conf/__init__.py", line 66, in _setup
self._wrapped = Settings(settings_module)
File "/app/.heroku/python/lib/python3.6/site-packages/django/conf/__init__.py", line 157, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "/app/.heroku/python/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 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 "/app/promotion/settings.py", line 27, in <module>
DEBUG = config('DEBUG', default=False, cast=bool)
File "/app/.heroku/python/lib/python3.6/site-packages/decouple.py", line 197, in __call__
return self.config(*args, **kwargs)
File "/app/.heroku/python/lib/python3.6/site-packages/decouple.py", line 85, in __call__
return self.get(*args, **kwargs)
File "/app/.heroku/python/lib/python3.6/site-packages/decouple.py", line 79, in get
return cast(value)
File "/app/.heroku/python/lib/python3.6/site-packages/decouple.py", line 50, in _cast_boolean
raise ValueError('Not a boolean: %s' % value)
ValueError: Not a boolean: True
Your screenshot shows a DEBUG environment variable whose value contains extra whitespace.
Depending on how you use that variable, the whitespace could easily caus problems. Delete that extra whitespace and see if that fixes things.
Also, you've partly revealed your SECRET_KEY and PostgreSQL credentials. Please change the SECRET_KEY and rotate your database credentials. Your current values are no longer secure.
I have an error when i use django.
Traceback (most recent call last):
File "manage.py", line 15, in <module>
execute_from_command_line(sys.argv)
File "/Users/ghk/djangoprojects/myvenv/lib/python3.6/site-packages/django/core/management/__init__.py", line 364, in execute_from_command_line
utility.execute()
File "/Users/ghk/djangoprojects/myvenv/lib/python3.6/site-packages/django/core/management/__init__.py", line 308, in execute
settings.INSTALLED_APPS
File "/Users/ghk/djangoprojects/myvenv/lib/python3.6/site-packages/django/conf/__init__.py", line 56, in __getattr__
self._setup(name)
File "/Users/ghk/djangoprojects/myvenv/lib/python3.6/site-packages/django/conf/__init__.py", line 41, in _setup
self._wrapped = Settings(settings_module)
File "/Users/ghk/djangoprojects/myvenv/lib/python3.6/site-packages/django/conf/__init__.py", line 110, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "/Library/Frameworks/Python.framework/Versions/3.6/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 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 "/Users/ghk/djangoprojects/lab-in-the-wild/labinthewild/settings.py", line 18, in <module>
from config import *
ModuleNotFoundError: No module named 'config'
If I command 'python manage.py runserver', it show this error.
As you said in your comments, you cloned this project from git.
Perhaps config is a local settings file you are meant to create yourself. Check the README and also check for a config example of some sorts