django 1.11
python 3.6.3
I've been working on an initial django app and just changed the views, models and forms from individual files to directories. My development machine is a windows box running the latest PyCharm. I then "deployed" the updated files to a linux test machine.
On the linux machine I did makemigrations
and migrate
and that seemed to work. I then visited the site...
Traceback (most recent call last):
File "/dh/passenger/helper-scripts/wsgi-loader.py", line 320, in <module>
app_module = load_app()
File "/dh/passenger/helper-scripts/wsgi-loader.py", line 61, in load_app
return imp.load_source('passenger_wsgi', startup_file)
File "/home/me/.pyenv/versions/3.5.2/lib/python3.5/imp.py", line 172, in load_source
module = _load(spec)
File "<frozen importlib._bootstrap>", line 693, in _load
File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 665, in exec_module
File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
File "passenger_wsgi.py", line 23, in <module>
application = get_wsgi_application()
File "/home/me/.pyenv/versions/3.5.2/lib/python3.5/site-packages/django/core/wsgi.py", line 13, in get_wsgi_application
django.setup(set_prefix=False)
File "/home/me/.pyenv/versions/3.5.2/lib/python3.5/site-packages/django/__init__.py", line 22, in setup
configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
File "/home/me/.pyenv/versions/3.5.2/lib/python3.5/site-packages/django/conf/__init__.py", line 56, in __getattr__
self._setup(name)
File "/home/me/.pyenv/versions/3.5.2/lib/python3.5/site-packages/django/conf/__init__.py", line 41, in _setup
self._wrapped = Settings(settings_module)
File "/home/me/.pyenv/versions/3.5.2/lib/python3.5/site-packages/django/conf/__init__.py", line 110, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "/home/me/.pyenv/versions/3.5.2/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 956, in _find_and_load_unlocked
ImportError: No module named 'MyProject.settings'
I've done a fair amount of googling and see lots of issues of this kind but I have not found a solution.
I have tested the wsgi
startup script and all the paths it builds/uses are correct and valid. The project looks like (pruned for brevity):
devSiteBase
|-- MyProject
| |-- MyProject
| | |-- __init__.py
| | |-- settings.py
| | |-- urls.py
| | `-- wsgi.py
| |-- Members
| | |-- __init__.py
| | |-- admin.py
| | |-- apps.py
| | |-- forms
| | | |-- ...
| | | |-- __init__.py
| | |-- models
| | | |-- ...
| | | |-- __init__.py
| | |-- tests.py
| | |-- urls.py
| | `-- views
| | |-- ...
| | |-- __init__.py
| |-- __init__.py
| |-- manage.py
| `-- templates
| |-- ...
|-- passenger_wsgi.py
|-- public
| |-- ...
the wsgi
startup script:
import os
import sys
from django.core.wsgi import get_wsgi_application
cwd = os.getcwd()
sys.path.append(cwd)
sys.path.append(os.path.join(cwd, 'MyProject'))
sys.path.append(os.path.join(cwd, 'MyProject/MyProject'))
HOME_DIR = os.path.expanduser('~')
INTERP = os.path.join(HOME_DIR, ".pyenv/versions/3.5.2/bin/python")
if sys.executable != INTERP:
os.execl(INTERP, INTERP, *sys.argv)
sys.path.insert(0, os.path.join(HOME_DIR, '.pyenv/versions/3.5.2/bin'))
sys.path.insert(0, os.path.join(HOME_DIR, '.pyenv/versions/3.5.2/lib/python3.5/site-packages'))
os.environ['DJANGO_SETTINGS_MODULE'] = 'MyProject.settings'
application = get_wsgi_application()
I can run python manage.py diffsettings
and that can obviously read the settings file.
Edit This issue is showing up on the linux platform not the PC.