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!
Related
Please I'm trying to implement Django AMP in my site so According to the docs here https://django-amp-tools.readthedocs.io/en/latest/installation.html.
I have added the required to my settings.py but still getting this error below
(my_venv) ~/my_venv/amp $ python manage.py runserver
Watching for file changes with StatReloader Exception in thread django-main-thread:
Traceback (most recent call last): File "/data/data/com.termux/files/usr/lib/python3.11/threading.py", line 1038, in _bootstrap_inner
self.run() File "/data/data/com.termux/files/usr/lib/python3.11/threading.py", line 975, in run
self._target(*self._args, **self._kwargs)
File "/data/data/com.termux/files/home/my_venv/lib/python3.11/site-packages/django/utils/autoreload.py", line 64, in wrapper
fn(*args, **kwargs) File "/data/data/com.termux/files/home/my_venv/lib/python3.11/site-packages/django/core/management/commands/runserver.py", line 125, in inner_run
autoreload.raise_last_exception()
File "/data/data/com.termux/files/home/my_venv/lib/python3.11/site-packages/django/utils/autoreload.py", line 87, in raise_last_exception
raise _exception[1]
File "/data/data/com.termux/files/home/my_venv/lib/python3.11/site-packages/django/core/management/__init__.py", line 398, in execute
autoreload.check_errors(django.setup)()
File "/data/data/com.termux/files/home/my_venv/lib/python3.11/site-packages/django/utils/autoreload.py", line 64, in wrapper
fn(*args, **kwargs)
File "/data/data/com.termux/files/home/my_venv/lib/python3.11/site-packages/django/__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "/data/data/com.termux/files/home/my_venv/lib/python3.11/site-packages/django/apps/registry.py", line 91, in populate
app_config = AppConfig.create(entry)
^^^^^^^^^^^^^^^^^^^^^^^
File "/data/data/com.termux/files/home/my_venv/lib/python3.11/site-packages/django/apps/config.py", line 193, in create
import_module(entry)
File "/data/data/com.termux/files/usr/lib/python3.11/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<frozen importlib._bootstrap>", line 1206, in _gcd_import
File "<frozen importlib._bootstrap>", line 1178, in _find_and_load
File "<frozen importlib._bootstrap>", line 1149, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 940, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "/data/data/com.termux/files/home/my_venv/lib/python3.11/site-packages/amp_tools/__init__.py", line 4, in <module>
from amp_tools.settings import settings
File "/data/data/com.termux/files/home/my_venv/lib/python3.11/site-packages/amp_tools/settings.py", line 25, in <module>
class defaults(object):
File "/data/data/com.termux/files/home/my_venv/lib/python3.11/site-packages/amp_tools/settings.py", line 39, in defaults
TEMPLATES = django_settings.TEMPLATES[0]['OPTIONS']['loaders']
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^
KeyError: 'loaders'
So please how can I solve this error
I added amp_tools.loader.Loader as first item to my loaders list for TEMPLATES setting in settings.py.
but still this error still coming up, how can i implement django accelerated page on my site if this doesn't work well
I am working on localization of a Django app, and the requirement dictated us to have 2 type of Traditional Chinese-- Taiwan and Hong Kong.
However, looking at the Django code,
...
...
("vi", gettext_noop("Vietnamese")),
("zh-hans", gettext_noop("Simplified Chinese")),
("zh-hant", gettext_noop("Traditional Chinese")),
]
It seems to only support one Traditional Chinese language.
I tried putting the language zh-hant-hk in setings.py. But instead of falling back to the Traditional Chinese or English, I got an error instead.
$ python manage.py runserver
Watching for file changes with StatReloader
Exception in thread django-main-thread:
Traceback (most recent call last):
File "/usr/local/Cellar/python#3.9/3.9.10/Frameworks/Python.framework/Versions/3.9/lib/python3.9/threading.py", line 973, in _bootstrap_inner
self.run()
File "/usr/local/Cellar/python#3.9/3.9.10/Frameworks/Python.framework/Versions/3.9/lib/python3.9/threading.py", line 910, in run
self._target(*self._args, **self._kwargs)
File "/usr/local/lib/python3.9/site-packages/django/utils/autoreload.py", line 64, in wrapper
fn(*args, **kwargs)
File "/usr/local/lib/python3.9/site-packages/django/core/management/commands/runserver.py", line 125, in inner_run
autoreload.raise_last_exception()
File "/usr/local/lib/python3.9/site-packages/django/utils/autoreload.py", line 87, in raise_last_exception
raise _exception[1]
File "/usr/local/lib/python3.9/site-packages/django/core/management/__init__.py", line 398, in execute
autoreload.check_errors(django.setup)()
File "/usr/local/lib/python3.9/site-packages/django/utils/autoreload.py", line 64, in wrapper
fn(*args, **kwargs)
File "/usr/local/lib/python3.9/site-packages/django/__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "/usr/local/lib/python3.9/site-packages/django/apps/registry.py", line 116, in populate
app_config.import_models()
File "/usr/local/lib/python3.9/site-packages/django/apps/config.py", line 304, in import_models
self.models_module = import_module(models_module_name)
File "/usr/local/Cellar/python#3.9/3.9.10/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 "/usr/local/lib/python3.9/site-packages/django/contrib/auth/models.py", line 97, in <module>
class Group(models.Model):
File "/usr/local/lib/python3.9/site-packages/django/db/models/base.py", line 192, in __new__
new_class.add_to_class(obj_name, obj)
File "/usr/local/lib/python3.9/site-packages/django/db/models/base.py", line 369, in add_to_class
value.contribute_to_class(cls, name)
File "/usr/local/lib/python3.9/site-packages/django/db/models/fields/related.py", line 1882, in contribute_to_class
self.remote_field.through = create_many_to_many_intermediary_model(
File "/usr/local/lib/python3.9/site-packages/django/db/models/fields/related.py", line 1261, in create_many_to_many_intermediary_model
"verbose_name": _("%(from)s-%(to)s relationship")
File "/usr/local/lib/python3.9/site-packages/django/utils/functional.py", line 183, in __mod__
return str(self) % rhs
File "/usr/local/lib/python3.9/site-packages/django/utils/functional.py", line 147, in __text_cast
return func(*self.__args, **self.__kw)
File "/usr/local/lib/python3.9/site-packages/django/utils/translation/__init__.py", line 95, in gettext
return _trans.gettext(message)
File "/usr/local/lib/python3.9/site-packages/django/utils/translation/trans_real.py", line 374, in gettext
_default = _default or translation(settings.LANGUAGE_CODE)
File "/usr/local/lib/python3.9/site-packages/django/utils/translation/trans_real.py", line 287, in translation
_translations[language] = DjangoTranslation(language)
File "/usr/local/lib/python3.9/site-packages/django/utils/translation/trans_real.py", line 173, in __init__
raise OSError(
OSError: No translation files found for default language zh-Hant-hk.
Had been looking at the documentation but didn't seem to be mentioned anywhere...
I am having this issue when I try to run the server in Pycharm. I am new to Django and downloaded this project as a backend for my react application. I have generated a Secret Key using:
from django.core.management.utils import get_random_secret_key
print(get_random_secret_key())
exit()
I added this Secret key to settings.py file as well.
Error Log which I get:
Watching for file changes with StatReloader
Exception in thread django-main-thread:
Traceback (most recent call last):
File "C:\Users\zabim\AppData\Local\Programs\Python\Python39\lib\threading.py", line 973, in _bootstrap_inner
self.run()
File "C:\Users\zabim\AppData\Local\Programs\Python\Python39\lib\threading.py", line 910, in run
self._target(*self._args, **self._kwargs)
File "W:\Playlistify-main\Playlistify-main\server\venv\lib\site-packages\django\utils\autoreload.py", line 64, in wrapper
fn(*args, **kwargs)
File "W:\Playlistify-main\Playlistify-main\server\venv\lib\site-packages\django\core\management\commands\runserver.py", line 110, in inner_run
autoreload.raise_last_exception()
File "W:\Playlistify-main\Playlistify-main\server\venv\lib\site-packages\django\utils\autoreload.py", line 87, in raise_last_exception
raise _exception[1]
File "W:\Playlistify-main\Playlistify-main\server\venv\lib\site-packages\django\core\management\__init__.py", line 375, in execute
autoreload.check_errors(django.setup)()
File "W:\Playlistify-main\Playlistify-main\server\venv\lib\site-packages\django\utils\autoreload.py", line 64, in wrapper
fn(*args, **kwargs)
File "W:\Playlistify-main\Playlistify-main\server\venv\lib\site-packages\django\__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "W:\Playlistify-main\Playlistify-main\server\venv\lib\site-packages\django\apps\registry.py", line 122, in populate
app_config.ready()
File "W:\Playlistify-main\Playlistify-main\server\venv\lib\site-packages\django\contrib\admin\apps.py", line 27, in ready
self.module.autodiscover()
File "W:\Playlistify-main\Playlistify-main\server\venv\lib\site-packages\django\contrib\admin\__init__.py", line 24, in autodiscover
autodiscover_modules('admin', register_to=site)
File "W:\Playlistify-main\Playlistify-main\server\venv\lib\site-packages\django\utils\module_loading.py", line 47, in autodiscover_modules
import_module('%s.%s' % (app_config.name, module_to_search))
File "C:\Users\zabim\AppData\Local\Programs\Python\Python39\lib\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 "W:\Playlistify-main\Playlistify-main\server\venv\lib\site-packages\django\contrib\auth\admin.py", line 6, in <module>
from django.contrib.auth.forms import (
File "W:\Playlistify-main\Playlistify-main\server\venv\lib\site-packages\django\contrib\auth\forms.py", line 11, in <module>
from django.contrib.auth.tokens import default_token_generator
File "W:\Playlistify-main\Playlistify-main\server\venv\lib\site-packages\django\contrib\auth\tokens.py", line 117, in <module>
default_token_generator = PasswordResetTokenGenerator()
File "W:\Playlistify-main\Playlistify-main\server\venv\lib\site-packages\django\contrib\auth\tokens.py", line 18, in __init__
self.secret = self.secret or settings.SECRET_KEY
File "W:\Playlistify-main\Playlistify-main\server\venv\lib\site-packages\django\conf\__init__.py", line 90, in __getattr__
raise ImproperlyConfigured("The SECRET_KEY setting must not be empty.")
django.core.exceptions.ImproperlyConfigured: The SECRET_KEY setting must not be empty.
Go to your settings.py
SECRET_KEY = ""
There should already be a value, if not, copy paste the one from the print statement.
Have a look at the different module for the settings, you could have one for local, production and base for example, make sure all of them have a secret key.
Learn about secret key
This is very important to understand, I strongly advise to have a look at the Django Tutorial as this error should be obvious to most beginners in Django
Django errors when running via Virtual Environment: Exception in thread Django-main-thread. I am doing this in Venv and not sure where I am going wrong? Can someone please help?
Initially, I ran into this issue when I accidentally upgraded Django when PyCharm prompted it but after that, I created a Venv and moved my files over but the error seems to be persistent.
(venv) users-MacBook-Pro:myproject $ python manage.py runserver
Watching for file changes with StatReloader
Performing system checks...
Exception in thread django-main-thread:
Traceback (most recent call last):
File "/Users/venv/lib/python3.7/site-packages/django/template/utils.py", line 66, in __getitem__
return self._engines[alias]
KeyError: 'django'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/threading.py", line 926, in _bootstrap_inner
self.run()
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "/Users/Documents/venv/lib/python3.7/site-packages/django/utils/autoreload.py", line 54, in wrapper
fn(*args, **kwargs)
File "/Users/venv/lib/python3.7/site-packages/django/core/management/commands/runserver.py", line 117, in inner_run
self.check(display_num_errors=True)
File "/Users/venv/lib/python3.7/site-packages/django/core/management/base.py", line 390, in check
include_deployment_checks=include_deployment_checks,
File "/Users/venv/lib/python3.7/site-packages/django/core/management/base.py", line 377, in _run_checks
return checks.run_checks(**kwargs)
File "/Users/venv/lib/python3.7/site-packages/django/core/checks/registry.py", line 72, in run_checks
new_errors = check(app_configs=app_configs)
File "/Users/venv/lib/python3.7/site-packages/django/contrib/admin/checks.py", line 79, in check_dependencies
for engine in engines.all():
File "/Users/venv/lib/python3.7/site-packages/django/template/utils.py", line 90, in all
return [self[alias] for alias in self]
File "/Users/venv/lib/python3.7/site-packages/django/template/utils.py", line 90, in <listcomp>
return [self[alias] for alias in self]
File "/Users/venv/lib/python3.7/site-packages/django/template/utils.py", line 81, in __getitem__
engine = engine_cls(params)
File "/Users/Documents/venv/lib/python3.7/site-packages/django/template/backends/django.py", line 25, in __init__
options['libraries'] = self.get_templatetag_libraries(libraries)
File "/Users/venv/lib/python3.7/site-packages/django/template/backends/django.py", line 43, in get_templatetag_libraries
libraries = get_installed_libraries()
File "/Users/venv/lib/python3.7/site-packages/django/template/backends/django.py", line 108, in get_installed_libraries
for name in get_package_libraries(pkg):
File "/Users/venv/lib/python3.7/site-packages/django/template/backends/django.py", line 121, in get_package_libraries
module = import_module(entry[1])
File "/Users/venv/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/venv/lib/python3.7/site-packages/rest_framework/templatetags/rest_framework.py", line 15, in <module>
from rest_framework.renderers import HTMLFormRenderer
File "/Users/venv/lib/python3.7/site-packages/rest_framework/renderers.py", line 20, in <module>
from django.test.client import encode_multipart
File "/Users/venv/lib/python3.7/site-packages/django/test/client.py", line 23, in <module>
from django.test import signals
File "<frozen importlib._bootstrap>", line 980, in _find_and_load
File "<frozen importlib._bootstrap>", line 149, in __enter__
File "<frozen importlib._bootstrap>", line 94, in acquire
_frozen_importlib._DeadlockError: deadlock detected by _ModuleLock('django.test.signals') at 4373516432
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).