我已在Wamp服务器中部署了Django应用程序,该工作正常。不幸的是,在运行pip安装后,Wamp服务器停止服务Django应用程序并抛出以下错误
mod_wsgi (pid=26240): Target WSGI script 'D:/testdeployment/mysite/mysite/wsgi.py' cannot be loaded as Python module.
mod_wsgi (pid=26240): Exception occurred processing WSGI script 'D:/testdeployment/mysite/mysite/wsgi.py'.
Traceback (most recent call last):
File "D:/testdeployment/mysite/mysite/wsgi.py", line 16, in <module>
application = get_wsgi_application()
File "C:\\Python27\\lib\\site-packages\\django-1.9.4-py2.7.egg\\django\\core\\wsgi.py", line 13, in get_wsgi_application
django.setup()
File "C:\\Python27\\lib\\site-packages\\django-1.9.4-py2.7.egg\\django\\__init__.py", line 17, in setup
configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
File "C:\\Python27\\lib\\site-packages\\django-1.9.4-py2.7.egg\\django\\conf\\__init__.py", line 55, in __getattr__
self._setup(name)
File "C:\\Python27\\lib\\site-packages\\django-1.9.4-py2.7.egg\\django\\conf\\__init__.py", line 43, in _setup
self._wrapped = Settings(settings_module)
File "C:\\Python27\\lib\\site-packages\\django-1.9.4-py2.7.egg\\django\\conf\\__init__.py", line 99, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "C:\\Python27\\Lib\\importlib\\__init__.py", line 37, in import_module
__import__(name)
ImportError: No module named mysite.settings
WSGI.PY
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mysite.settings")
application = get_wsgi_application()
Wamp配置:
WSGIScriptAlias / "D:/testdeployment/mysite/mysite/wsgi.py"
WSGIPythonPath "D:/testdeployment/mysite/mysite/"
<Directory "D:/testdeployment/mysite/mysite/">
Order deny,allow
Allow from all
Require all granted
</Directory>
<Directory "D:/testdeployment/mysite/mysite/">
<Files wsgi.py>
Require all granted
</Files>
SSLOptions +StdEnvVars
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require local
</Directory>
请告诉我这里的问题
答案 0 :(得分:0)
python路径应该是外部mysite
目录(包含manage.py
的目录),而不是内部mysite
目录(包含settings.py
和wsgi.py
的目录})。
WSGIPythonPath "D:/testdeployment/mysite/"
有关详细信息,请参阅deploying with Apache and mod_wsgi的Django文档。
答案 1 :(得分:0)
我遇到了同样的问题,但是当我通过文件资源管理器查看文件的位置时,我知道我的文件放置不正确,例如mysite.settings的django搜索器,但是我有一个名为mysite的文件夹,并且在该文件夹中我有mysite文件,因此django找不到我的文件。尝试查看文件排列。