I'm trying to run the following command in my Ubuntu server:
./manage.py collectstatic -v 0 --noinput
and I'm getting this error message:
Traceback (most recent call last):
File "./manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/home/ubuntu/.virtualenvs/project/lib/python3.4/site-packages/django/core/management/__init__.py", line 353, in execute_from_command_line
utility.execute()
File "/home/ubuntu/.virtualenvs/project/lib/python3.4/site-packages/django/core/management/__init__.py", line 327, in execute
django.setup()
File "/home/ubuntu/.virtualenvs/project/lib/python3.4/site-packages/django/__init__.py", line 18, in setup
apps.populate(settings.INSTALLED_APPS)
File "/home/ubuntu/.virtualenvs/project/lib/python3.4/site-packages/django/apps/registry.py", line 115, in populate
app_config.ready()
File "/home/ubuntu/.virtualenvs/project/lib/python3.4/site-packages/django/contrib/admin/apps.py", line 22, in ready
self.module.autodiscover()
File "/home/ubuntu/.virtualenvs/project/lib/python3.4/site-packages/django/contrib/admin/__init__.py", line 26, in autodiscover
autodiscover_modules('admin', register_to=site)
File "/home/ubuntu/.virtualenvs/project/lib/python3.4/site-packages/django/utils/module_loading.py", line 50, in autodiscover_modules
import_module('%s.%s' % (app_config.name, module_to_search))
File "/home/ubuntu/.virtualenvs/project/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/ubuntu/.virtualenvs/project/lib/python3.4/site-packages/django/contrib/auth/admin.py", line 7, in <module>
from django.contrib.auth.forms import (
File "/home/ubuntu/.virtualenvs/project/lib/python3.4/site-packages/django/contrib/auth/forms.py", line 262, in <module>
class SetPasswordForm(forms.Form):
File "/home/ubuntu/.virtualenvs/project/lib/python3.4/site-packages/django/contrib/auth/forms.py", line 272, in SetPasswordForm
help_text=password_validation.password_validators_help_text_html())
File "/home/ubuntu/.virtualenvs/project/lib/python3.4/site-packages/django/contrib/auth/password_validation.py", line 85, in password_validators_help_text_html
help_texts = password_validators_help_texts(password_validators)
File "/home/ubuntu/.virtualenvs/project/lib/python3.4/site-packages/django/contrib/auth/password_validation.py", line 76, in password_validators_help_texts
help_texts.append(validator.get_help_text())
File "/home/ubuntu/.virtualenvs/project/lib/python3.4/site-packages/django/contrib/auth/password_validation.py", line 153, in get_help_text
return _("Your password can't be too similar to your other personal information.")
File "/home/ubuntu/.virtualenvs/project/lib/python3.4/site-packages/django/utils/translation/__init__.py", line 85, in ugettext
return _trans.ugettext(message)
File "/home/ubuntu/.virtualenvs/project/lib/python3.4/site-packages/django/utils/translation/trans_real.py", line 312, in gettext
return do_translate(message, 'gettext')
File "/home/ubuntu/.virtualenvs/project/lib/python3.4/site-packages/django/utils/translation/trans_real.py", line 295, in do_translate
_default = _default or translation(settings.LANGUAGE_CODE)
File "/home/ubuntu/.virtualenvs/project/lib/python3.4/site-packages/django/utils/translation/trans_real.py", line 202, in translation
_translations[language] = DjangoTranslation(language)
File "/home/ubuntu/.virtualenvs/project/lib/python3.4/site-packages/django/utils/translation/trans_real.py", line 115, in __init__
self._add_local_translations()
File "/home/ubuntu/.virtualenvs/project/lib/python3.4/site-packages/django/utils/translation/trans_real.py", line 163, in _add_local_translations
translation = self._new_gnu_trans(localedir)
File "/home/ubuntu/.virtualenvs/project/lib/python3.4/site-packages/django/utils/translation/trans_real.py", line 137, in _new_gnu_trans
fallback=use_null_fallback)
File "/usr/lib/python3.4/gettext.py", line 428, in translation
t = _translations.setdefault(key, class_(fp))
File "/usr/lib/python3.4/gettext.py", line 162, in __init__
self._parse(fp)
File "/usr/lib/python3.4/gettext.py", line 241, in _parse
magic = unpack('<I', buf[:4])[0]
struct.error: unpack requires a bytes object of length 4
What could it be? The error seems quite unrelated.
Seems like you have an empty django.mo file (.mo files are those that contain translations). Consider removing it, or re-creating it or or re-installing Django.
I figured it out because:
the problem was raised by gettext;
the exception was raised while parsing the header of the file; and
the exception is about a bytestring that is too short (possibly empty).
Related
I am learning Django during this lock-down. My app has been running properly , made some changes like adding models ,etc and hit runserver and got errors below:
PS C:\Users\RK\RentalMgt\TenancyMgt> python manage.py runserver
Watching for file changes with StatReloader
Exception in thread django-main-thread:
Traceback (most recent call last):
File "C:\ProgramData\Anaconda3\lib\threading.py", line 917, in _bootstrap_inner
self.run()
File "C:\ProgramData\Anaconda3\lib\threading.py", line 865, in run
self._target(*self._args, **self._kwargs)
File "C:\ProgramData\Anaconda3\lib\site-packages\django\utils\autoreload.py", line 53, in wrapper
fn(*args, **kwargs)
File "C:\ProgramData\Anaconda3\lib\site-packages\django\core\management\commands\runserver.py", line 109, in inner_run
autoreload.raise_last_exception()
File "C:\ProgramData\Anaconda3\lib\site-packages\django\utils\autoreload.py", line 76, in raise_last_exception
raise _exception[1]
File "C:\ProgramData\Anaconda3\lib\site-packages\django\core\management\__init__.py", line 357, in execute
autoreload.check_errors(django.setup)()
File "C:\ProgramData\Anaconda3\lib\site-packages\django\utils\autoreload.py", line 53, in wrapper
fn(*args, **kwargs)
File "C:\ProgramData\Anaconda3\lib\site-packages\django\__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "C:\ProgramData\Anaconda3\lib\site-packages\django\apps\registry.py", line 114, in populate
app_config.import_models()
File "C:\ProgramData\Anaconda3\lib\site-packages\django\apps\config.py", line 211, in import_models
self.models_module = import_module(models_module_name)
File "C:\ProgramData\Anaconda3\lib\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 724, in exec_module
File "<frozen importlib._bootstrap_external>", line 860, in get_code
File "<frozen importlib._bootstrap_external>", line 791, in source_to_code
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
ValueError: source code string cannot contain null bytes
Traceback (most recent call last):
File "manage.py", line 21, in <module>
main()
File "manage.py", line 17, in main
execute_from_command_line(sys.argv)
File "C:\ProgramData\Anaconda3\lib\site-packages\django\core\management\__init__.py", line 401, in execute_from_command_line
utility.execute()
File "C:\ProgramData\Anaconda3\lib\site-packages\django\core\management\__init__.py", line 395, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\ProgramData\Anaconda3\lib\site-packages\django\core\management\base.py", line 328, in run_from_argv
self.execute(*args, **cmd_options)
File "C:\ProgramData\Anaconda3\lib\site-packages\django\core\management\commands\runserver.py", line 60, in execute
super().execute(*args, **options)
File "C:\ProgramData\Anaconda3\lib\site-packages\django\core\management\base.py", line 369, in execute
output = self.handle(*args, **options)
File "C:\ProgramData\Anaconda3\lib\site-packages\django\core\management\commands\runserver.py", line 95, in handle
self.run(**options)
File "C:\ProgramData\Anaconda3\lib\site-packages\django\core\management\commands\runserver.py", line 102, in run
autoreload.run_with_reloader(self.inner_run, **options)
File "C:\ProgramData\Anaconda3\lib\site-packages\django\utils\autoreload.py", line 599, in run_with_reloader
start_django(reloader, main_func, *args, **kwargs)
File "C:\ProgramData\Anaconda3\lib\site-packages\django\utils\autoreload.py", line 584, in start_django
reloader.run(django_main_thread)
File "C:\ProgramData\Anaconda3\lib\site-packages\django\utils\autoreload.py", line 299, in run
self.run_loop()
File "C:\ProgramData\Anaconda3\lib\site-packages\django\utils\autoreload.py", line 305, in run_loop
next(ticker)
File "C:\ProgramData\Anaconda3\lib\site-packages\django\utils\autoreload.py", line 345, in tick
for filepath, mtime in self.snapshot_files():
File "C:\ProgramData\Anaconda3\lib\site-packages\django\utils\autoreload.py", line 361, in snapshot_files
for file in self.watched_files():
File "C:\ProgramData\Anaconda3\lib\site-packages\django\utils\autoreload.py", line 260, in watched_files
yield from iter_all_python_module_files()
File "C:\ProgramData\Anaconda3\lib\site-packages\django\utils\autoreload.py", line 105, in iter_all_python_module_files
return iter_modules_and_files(modules, frozenset(_error_files))
File "C:\ProgramData\Anaconda3\lib\site-packages\django\utils\autoreload.py", line 141, in iter_modules_and_files
resolved_path = path.resolve(strict=True).absolute()
File "C:\ProgramData\Anaconda3\lib\pathlib.py", line 1144, in resolve
s = self._flavour.resolve(self, strict=strict)
File "C:\ProgramData\Anaconda3\lib\pathlib.py", line 196, in resolve
return self._ext_to_normal(_getfinalpathname(s))
OSError: [WinError 123] The filename, directory name, or volume label syntax is incorrect: '<frozen importlib._bootstrap>'
I have searched online and got some suggestions like running the migration and makemigrations command.
The above have not worked(they also cause errors but they were working previously.
Example running migrate causes the error below:
PS C:\Users\RK\RentalMgt\TenancyMgt> python manage.py migrate
Traceback (most recent call last):
File "manage.py", line 21, in <module>
main()
File "manage.py", line 17, in main
execute_from_command_line(sys.argv)
File "C:\ProgramData\Anaconda3\lib\site-packages\django\core\management\__init__.py", line 401, in execute_from_command_line
utility.execute()
File "C:\ProgramData\Anaconda3\lib\site-packages\django\core\management\__init__.py", line 377, in execute
django.setup()
File "C:\ProgramData\Anaconda3\lib\site-packages\django\__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "C:\ProgramData\Anaconda3\lib\site-packages\django\apps\registry.py", line 114, in populate
app_config.import_models()
File "C:\ProgramData\Anaconda3\lib\site-packages\django\apps\config.py", line 211, in import_models
self.models_module = import_module(models_module_name)
File "C:\ProgramData\Anaconda3\lib\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 724, in exec_module
File "<frozen importlib._bootstrap_external>", line 860, in get_code
File "<frozen importlib._bootstrap_external>", line 791, in source_to_code
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
ValueError: source code string cannot contain null bytes
PS C:\Users\RK\RentalMgt\TenancyMgt>
I thinking of starting a fresh project but what happens if i get a similar error in future?
Any pointers on how to solve the problem are highly appreciated.
Ronald
Running: python manage.py inspectdb --database=geoserver > map/models.py
After: python manage.py runserver gives below errors:
Watching for file changes with StatReloader
Exception in thread Thread-1:
Traceback (most recent call last):
File "C:\Users\Hassan\Miniconda3\lib\threading.py", line 926, in _bootstrap_inner
self.run()
File "C:\Users\Hassan\Miniconda3\lib\threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "d:\DSS2.0\venv\lib\site-packages\django\utils\autoreload.py", line 54, in wrapper
fn(*args, **kwargs)
File "d:\DSS2.0\venv\lib\site-packages\django\core\management\commands\runserver.py", line 109, in
inner_run
autoreload.raise_last_exception()
File "d:\DSS2.0\venv\lib\site-packages\django\utils\autoreload.py", line 77, in raise_last_exception
raise _exception[0](_exception[1]).with_traceback(_exception[2])
File "d:\DSS2.0\venv\lib\site-packages\django\utils\autoreload.py", line 54, in wrapper
fn(*args, **kwargs)
File "d:\DSS2.0\venv\lib\site-packages\django\__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "d:\DSS2.0\venv\lib\site-packages\django\apps\registry.py", line 114, in populate
app_config.import_models()
File "d:\DSS2.0\venv\lib\site-packages\django\apps\config.py", line 211, in import_models
self.models_module = import_module(models_module_name)
File "C:\Users\Hassan\Miniconda3\lib\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 724, in exec_module
File "<frozen importlib._bootstrap_external>", line 860, in get_code
File "<frozen importlib._bootstrap_external>", line 791, in source_to_code
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
ValueError: source code string cannot contain null bytes
Traceback (most recent call last):
File "d:\DSS2.0\venv\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 24, in <module>
main()
File "manage.py", line 20, in main
execute_from_command_line(sys.argv)
File "d:\DSS2.0\venv\lib\site-packages\django\core\management\__init__.py", line 381, in
execute_from_command_line
utility.execute()
File "d:\DSS2.0\venv\lib\site-packages\django\core\management\__init__.py", line 375, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "d:\DSS2.0\venv\lib\site-packages\django\core\management\base.py", line 323, in run_from_argv
self.execute(*args, **cmd_options)
File "d:\DSS2.0\venv\lib\site-packages\django\core\management\commands\runserver.py", line 60, in
execute
super().execute(*args, **options)
File "d:\DSS2.0\venv\lib\site-packages\django\core\management\base.py", line 364, in execute
output = self.handle(*args, **options)
File "d:\DSS2.0\venv\lib\site-packages\django\core\management\commands\runserver.py", line 95, in
handle
self.run(**options)
File "d:\DSS2.0\venv\lib\site-packages\django\core\management\commands\runserver.py", line 102, in
run
autoreload.run_with_reloader(self.inner_run, **options)
File "d:\DSS2.0\venv\lib\site-packages\django\utils\autoreload.py", line 579, in run_with_reloader
start_django(reloader, main_func, *args, **kwargs)
File "d:\DSS2.0\venv\lib\site-packages\django\utils\autoreload.py", line 564, in start_django
reloader.run(django_main_thread)
File "d:\DSS2.0\venv\lib\site-packages\django\utils\autoreload.py", line 272, in run
get_resolver().urlconf_module
File "d:\DSS2.0\venv\lib\site-packages\django\utils\functional.py", line 80, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "d:\DSS2.0\venv\lib\site-packages\django\urls\resolvers.py", line 564, in urlconf_module
return import_module(self.urlconf_name)
File "C:\Users\Hassan\Miniconda3\lib\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 "D:\dss2.0\dss\urls.py", line 21, in <module>
path('admin/', admin.site.urls),
File "d:\DSS2.0\venv\lib\site-packages\django\utils\functional.py", line 256, in inner
self._setup()
File "d:\DSS2.0\venv\lib\site-packages\django\contrib\admin\sites.py", line 529, in _setup
AdminSiteClass = import_string(apps.get_app_config('admin').default_site)
File "d:\DSS2.0\venv\lib\site-packages\django\apps\registry.py", line 162, in get_app_config
raise LookupError(message)
LookupError: No installed app with label 'admin'.
Note: If you are facing same issue, please try my approach given in answer section, it may work for you as well.
To get rid of above error, i used some Jugad method written below:
first i ran below command to generate model:
python manage.py inspectdb --database=geoserver > map/models.py
Then i cut models.py code and ran: django-admin inspectdb --database=geoserver > map/models.py
this command removed my model code bcz of some db config issue.
After that i pasted by code in model.py and used python manage.py runserver
Finally it worked.
This question already has answers here:
"No installed app with label 'admin'" in empty Django 2.2 project
(2 answers)
Closed 2 years ago.
My Django project was created by 2.0.8, and I want to update the Django's version because the Doc say "This document is for an insecure version of Django that is no longer supported. Please upgrade to a newer release!".And after the update when I re-use the command python manager.py runserver, the Error was raised:
"Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/threading.py", line 916, in _bootstrap_inner
self.run()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/threading.py", line 864, in run
self._target(*self._args, **self._kwargs)
File "/Users/duke/Documents/python/django_test/env/lib/python3.6/site-packages/django/utils/autoreload.py", line 54, in wrapper
fn(*args, **kwargs)
File "/Users/duke/Documents/python/django_test/env/lib/python3.6/site-packages/django/core/management/commands/runserver.py", line 109, in inner_run
autoreload.raise_last_exception()
File "/Users/duke/Documents/python/django_test/env/lib/python3.6/site-packages/django/utils/autoreload.py", line 77, in raise_last_exception
raise _exception[0](_exception[1]).with_traceback(_exception[2])
File "/Users/duke/Documents/python/django_test/env/lib/python3.6/site-packages/django/utils/autoreload.py", line 54, in wrapper
fn(*args, **kwargs)
File "/Users/duke/Documents/python/django_test/env/lib/python3.6/site-packages/django/__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "/Users/duke/Documents/python/django_test/env/lib/python3.6/site-packages/django/apps/registry.py", line 114, in populate
app_config.import_models()
File "/Users/duke/Documents/python/django_test/env/lib/python3.6/site-packages/django/apps/config.py", line 211, in import_models
self.models_module = import_module(models_module_name)
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/duke/Documents/python/django_test/env/lib/python3.6/site-packages/django/contrib/auth/models.py", line 2, in <module>
from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager
File "/Users/duke/Documents/python/django_test/env/lib/python3.6/site-packages/django/contrib/auth/base_user.py", line 47, in <module>
class AbstractBaseUser(models.Model):
File "/Users/duke/Documents/python/django_test/env/lib/python3.6/site-packages/django/db/models/base.py", line 117, in __new__
new_class.add_to_class('_meta', Options(meta, app_label))
File "/Users/duke/Documents/python/django_test/env/lib/python3.6/site-packages/django/db/models/base.py", line 321, in add_to_class
value.contribute_to_class(cls, name)
File "/Users/duke/Documents/python/django_test/env/lib/python3.6/site-packages/django/db/models/options.py", line 204, in contribute_to_class
self.db_table = truncate_name(self.db_table, connection.ops.max_name_length())
File "/Users/duke/Documents/python/django_test/env/lib/python3.6/site-packages/django/db/__init__.py", line 28, in __getattr__
return getattr(connections[DEFAULT_DB_ALIAS], item)
File "/Users/duke/Documents/python/django_test/env/lib/python3.6/site-packages/django/db/utils.py", line 201, in __getitem__
backend = load_backend(db['ENGINE'])
File "/Users/duke/Documents/python/django_test/env/lib/python3.6/site-packages/django/db/utils.py", line 110, in load_backend
return import_module('%s.base' % backend_name)
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 "/Users/duke/Documents/python/django_test/env/lib/python3.6/site-packages/django/db/backends/mysql/base.py", line 36, in <module>
raise ImproperlyConfigured('mysqlclient 1.3.13 or newer is required; you have %s.' % Database.__version__)
django.core.exceptions.ImproperlyConfigured: mysqlclient 1.3.13 or newer is required; you have 0.9.3.
Traceback (most recent call last):
File "/Users/duke/Documents/python/django_test/env/lib/python3.6/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 "../KitCat/manage.py", line 15, in <module>
execute_from_command_line(sys.argv)
File "/Users/duke/Documents/python/django_test/env/lib/python3.6/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
utility.execute()
File "/Users/duke/Documents/python/django_test/env/lib/python3.6/site-packages/django/core/management/__init__.py", line 375, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Users/duke/Documents/python/django_test/env/lib/python3.6/site-packages/django/core/management/base.py", line 323, in run_from_argv
self.execute(*args, **cmd_options)
File "/Users/duke/Documents/python/django_test/env/lib/python3.6/site-packages/django/core/management/commands/runserver.py", line 60, in execute
super().execute(*args, **options)
File "/Users/duke/Documents/python/django_test/env/lib/python3.6/site-packages/django/core/management/base.py", line 364, in execute
output = self.handle(*args, **options)
File "/Users/duke/Documents/python/django_test/env/lib/python3.6/site-packages/django/core/management/commands/runserver.py", line 95, in handle
self.run(**options)
File "/Users/duke/Documents/python/django_test/env/lib/python3.6/site-packages/django/core/management/commands/runserver.py", line 102, in run
autoreload.run_with_reloader(self.inner_run, **options)
File "/Users/duke/Documents/python/django_test/env/lib/python3.6/site-packages/django/utils/autoreload.py", line 579, in run_with_reloader
start_django(reloader, main_func, *args, **kwargs)
File "/Users/duke/Documents/python/django_test/env/lib/python3.6/site-packages/django/utils/autoreload.py", line 564, in start_django
reloader.run(django_main_thread)
File "/Users/duke/Documents/python/django_test/env/lib/python3.6/site-packages/django/utils/autoreload.py", line 272, in run
get_resolver().urlconf_module
File "/Users/duke/Documents/python/django_test/env/lib/python3.6/site-packages/django/utils/functional.py", line 80, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/Users/duke/Documents/python/django_test/env/lib/python3.6/site-packages/django/urls/resolvers.py", line 564, in urlconf_module
return import_module(self.urlconf_name)
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/duke/Documents/python/KitCat/KitCat/urls.py", line 21, in <module>
path('admin/', admin.site.urls),
File "/Users/duke/Documents/python/django_test/env/lib/python3.6/site-packages/django/utils/functional.py", line 256, in inner
self._setup()
File "/Users/duke/Documents/python/django_test/env/lib/python3.6/site-packages/django/contrib/admin/sites.py", line 529, in _setup
AdminSiteClass = import_string(apps.get_app_config('admin').default_site)
File "/Users/duke/Documents/python/django_test/env/lib/python3.6/site-packages/django/apps/registry.py", line 162, in get_app_config
raise LookupError(message)
LookupError: No installed app with label 'admin'."
BTW ,the project is all right under the version of 2.0.8
So my question is:
1.what was happened?
2.how to fix this?
3.Is there any other thing I need to know?
Thank you very much for helping me with this problem.
The real issue is buried in the traceback, your version of mysqlclient is outdated:
django.core.exceptions.ImproperlyConfigured: mysqlclient 1.3.13 or newer is required; you have 0.9.3.
Ok when i'm in django I can run the website by the following command.
sudo python manage.py runserver
But when I try and use the greed arrow for running the project is gives me like a dozen errors.
This happens straight away when i set up the project and was hoping if anyone could help.
Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x10484fbf8>
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/django/utils/autoreload.py", line 226, in wrapper
fn(*args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/django/core/management/commands/runserver.py", line 109, in inner_run
autoreload.raise_last_exception()
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/django/utils/autoreload.py", line 249, in raise_last_exception
six.reraise(*_exception)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/django/utils/six.py", line 685, in reraise
raise value.with_traceback(tb)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/django/utils/autoreload.py", line 226, in wrapper
fn(*args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/django/__init__.py", line 18, in setup
apps.populate(settings.INSTALLED_APPS)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/django/apps/registry.py", line 115, in populate
app_config.ready()
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/django/contrib/admin/apps.py", line 22, in ready
self.module.autodiscover()
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/django/contrib/admin/__init__.py", line 26, in autodiscover
autodiscover_modules('admin', register_to=site)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/django/utils/module_loading.py", line 50, in autodiscover_modules
import_module('%s.%s' % (app_config.name, module_to_search))
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 986, in _gcd_import
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 662, in exec_module
File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/django/contrib/auth/admin.py", line 7, in <module>
from django.contrib.auth.forms import (
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/django/contrib/auth/forms.py", line 264, in <module>
class SetPasswordForm(forms.Form):
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/django/contrib/auth/forms.py", line 275, in SetPasswordForm
help_text=password_validation.password_validators_help_text_html())
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/django/contrib/auth/password_validation.py", line 85, in password_validators_help_text_html
help_texts = password_validators_help_texts(password_validators)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/django/contrib/auth/password_validation.py", line 74, in password_validators_help_texts
password_validators = get_default_password_validators()
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/django/contrib/auth/password_validation.py", line 21, in get_default_password_validators
return get_password_validators(settings.AUTH_PASSWORD_VALIDATORS)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/django/contrib/auth/password_validation.py", line 32, in get_password_validators
validators.append(klass(**validator.get('OPTIONS', {})))
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/django/contrib/auth/password_validation.py", line 170, in __init__
common_passwords_lines = gzip.open(password_list_path).read().decode('utf-8').splitlines()
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x80 in position 0: invalid start byte
I know…
I was getting a similar error for a different issue, but it turned out that it was a problem with the way PyCharm handled Unicode/UTF-8 with Python 3. I ended up doing the following to get the error to go away.
Add following line in the file "pycharm.exe.vmoptions":
-Dfile.encoding=UTF-8
Source:
Why unicode string is not shown on PyCharm's console?
Hope this helps!
I am trying to use BradWhittington Django-Templated-Email. I installed it, and added the following lines in the settings.py.
from templated_email.backends.vanilla_django import TemplateBackend
TEMPLATED_EMAIL_BACKEND = TemplateBackend
When I try to run the server, I get the import error. Even when I use
from templated_email import send_templated_mail
in the models.py I again get the import error. I am new to django, and I googled for the answer many times. But no luck. What am I missing? The 'Run' window on pycharm shows the following:
"C:\Program Files\JetBrains\PyCharm 4.0.4\bin\runnerw.exe" "E:\***\***\***\env1\Scripts\python.exe" "C:\Program Files\JetBrains\PyCharm 4.0.4\helpers\pycharm\django_manage.py" syncdb "E:/***/***/***/***"
Traceback (most recent call last):
File "C:\Program Files\JetBrains\PyCharm 4.0.4\helpers\pycharm\django_manage.py", line 41, in <module>
run_module(manage_file, None, '__main__', True)
File "C:\Python34\Lib\runpy.py", line 182, in run_module
return _run_module_code(code, init_globals, run_name, mod_spec)
File "C:\Python34\Lib\runpy.py", line 96, in _run_module_code
mod_name, mod_spec, pkg_name, script_name)
File "C:\Python34\Lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "E:/***/***/***/***\manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "E:\***\***\***\env1\lib\site-packages\django\core\management\__init__.py", line 385, in execute_from_command_line
utility.execute()
File "E:\***\***\***\env1\lib\site-packages\django\core\management\__init__.py", line 345, in execute
settings.INSTALLED_APPS
File "E:\***\***\***\env1\lib\site-packages\django\conf\__init__.py", line 46, in __getattr__
self._setup(name)
File "E:\***\***\***\env1\lib\site-packages\django\conf\__init__.py", line 42, in _setup
self._wrapped = Settings(settings_module)
File "E:\***\***\***\env1\lib\site-packages\django\conf\__init__.py", line 94, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "E:\***\***\***\env1\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 "E:/***/***/***/***\***\settings.py", line 17, in <module>
from templated_email.backends.vanilla_django import TemplateBackend
File "E:\***\***\***\env1\lib\site-packages\templated_email\__init__.py", line 23
except ImportError, e:
^
SyntaxError: invalid syntax
Process finished with exit code 1
I am using virtual environment. Please help me.
Django-Templated-Email does not support python 3, which you are using.
You can migrate your project to python2, but it's better to find modern alternative to Django-Templated-Email.