[英]WSGI cannot be loaded as Python module
I'm getting this error 我收到这个错误
'path-to/wsgi.py' cannot be loaded as Python module. 无法将“ path-to / wsgi.py”作为Python模块加载。
I've never had it before having loaded many Python / Django projects by 在加载了许多Python / Django项目之前,我从未有过它
mkdir directory
cd directory
virtualenv env
env/bin/pip install -r requirements.txt
Then FTP in the files and then 然后在文件中使用FTP,然后
env/bin/python manage.py migrate
env/bin/python manage.py collectstatic
env/bin/python manage.py createsuperuser
Today it isn't working. 今天,它不起作用。 I've read a number of posts with similar issues but they seem to be due to different versions of python. 我读过许多有类似问题的帖子,但它们似乎是由于python版本不同所致。 Mine aren't. 我的不是。 Any ideas. 有任何想法吗。
EDIT Traceback added 添加了EDIT Traceback
mod_wsgi (pid=8982): Target WSGI script '/var/www/mattscott/mainapp/wsgi.py' cannot be loaded as Python module.
mod_wsgi (pid=8982): Exception occurred processing WSGI script '/var/www/mattscott/mainapp/wsgi.py'.
Traceback (most recent call last):
File "/var/www/mattscott/mainapp/wsgi.py", line 16, in <module>
application = get_wsgi_application()
File "/var/www/mattscott/env/lib/python2.7/site-packages/django/core/wsgi.py", line 13, in get_wsgi_application
django.setup(set_prefix=False)
File "/var/www/mattscott/env/lib/python2.7/site-packages/django/__init__.py", line 22, in setup
configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
File "/var/www/mattscott/env/lib/python2.7/site-packages/django/conf/__init__.py", line 53, in __getattr__
self._setup(name)
File "/var/www/mattscott/env/lib/python2.7/site-packages/django/conf/__init__.py", line 41, in _setup
self._wrapped = Settings(settings_module)
File "/var/www/mattscott/env/lib/python2.7/site-packages/django/conf/__init__.py", line 97, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
ImportError: No module named mainapp.settings
Found a solution but I expect it is the symptom of something else wrong (I'm hoping Graham will explain). 找到了解决方案,但我希望这是其他错误的症状(我希望Graham会解释)。
I've added: 我已经添加:
path = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
if path not in sys.path:
sys.path.append(path)
to wsgi.py
到wsgi.py
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.