This question is almost the same as How to run cloned Django project? but because this project only includes mysite/settings.pyc
, even the most basic commands fail in reference to Django settings.
$ python3 manage.py runserver
...
ImportError: bad magic number in 'mysite.settings': b'\x03\xf3\r\n'
$ django-admin runserver --settings=mysite.settings
...
ModuleNotFoundError: No module named 'mysite'
Trying other commands (e.g., python3 manage.py migrate
) fail with reference to the bad magic number in mysite.settings
.
The thread How to run a Django project with .pyc files without using source codes? seems to be exactly about this topic, but (1) the project is already structured as advised, and (2) that person answered their own question so they may tried that in the same dev environment.
This answer in the ImportError: bad magic number in 'time': b'\x03\xf3\r\n' in Django thread suggests that there are bytecode-only releases
(yeah, I'm new to Python) so am I missing something? (The rest of the answers are not applicable in my case as deleting all pyc
files would include deleting the settings.pyc
as well... This post on pyc
bytecode files was elucidating though.)
The DJANGO_SETTINGS_MODULE
environment variable is also properly set up (1, 2), and in this case it seems that the mysite.settings
module is simply missing.
Just in case this is relevant: I'm on NixOS so set up the Python3 environment with mach-nix
.