Я развертываю проект django и получаю эту ошибку 500 (см. Ошибка журнала сервера).Целевой скрипт WSGI '../wsgi.py' не может быть загружен как модуль Python
Где я делаю неправильно?
некоторые примечания:
- CentOS
- mod_wsgi установлен
- же питон (2.7) и Джанго (1.9.6) версии и в разработке и развертывании environement
- с использованием virtualenv в развертывания environement
Ошибка журнала сервера
[Wed Sep 21 17:07:54 2016] [error] [client 192.168.30.93] SyntaxError: invalid syntax
[Wed Sep 21 17:07:54 2016] [error] [client 192.168.30.93] mod_wsgi (pid=6570): Target WSGI script '/new_esmart/esmart2/esmart2/wsgi.py' cannot be loaded as Python module., referer: http://192.168.30.17/logistics/alarms/
[Wed Sep 21 17:07:54 2016] [error] [client 192.168.30.93] mod_wsgi (pid=6570): Exception occurred processing WSGI script '/new_esmart/esmart2/esmart2/wsgi.py'., referer: http://192.168.30.17/logistics/alarms/
[Wed Sep 21 17:07:54 2016] [error] [client 192.168.30.93] Traceback (most recent call last):, referer: http://192.168.30.17/logistics/alarms/
[Wed Sep 21 17:07:54 2016] [error] [client 192.168.30.93] File "/new_esmart/esmart2/esmart2/wsgi.py", line 13, in <module>, referer: http://192.168.30.17/logistics/alarms/
[Wed Sep 21 17:07:54 2016] [error] [client 192.168.30.93] import django.core.handlers.wsgi, referer: http://192.168.30.17/logistics/alarms/
[Wed Sep 21 17:07:54 2016] [error] [client 192.168.30.93] File "/new_esmart/esmart_env/lib/python2.7/site-packages/django/__init__.py", line 1, in <module>, referer: http://192.168.30.17/logistics/alarms/
[Wed Sep 21 17:07:54 2016] [error] [client 192.168.30.93] from django.utils.version import get_version, referer: http://192.168.30.17/logistics/alarms/
[Wed Sep 21 17:07:54 2016] [error] [client 192.168.30.93] File "/new_esmart/esmart_env/lib/python2.7/site-packages/django/utils/version.py", line 7, in <module>, referer: http://192.168.30.17/logistics/alarms/
[Wed Sep 21 17:07:54 2016] [error] [client 192.168.30.93] from django.utils.lru_cache import lru_cache, referer: http://192.168.30.17/logistics/alarms/
[Wed Sep 21 17:07:54 2016] [error] [client 192.168.30.93] File "/new_esmart/esmart_env/lib/python2.7/site-packages/django/utils/lru_cache.py", line 28, referer: http://192.168.30.17/logistics/alarms/
[Wed Sep 21 17:07:54 2016] [error] [client 192.168.30.93] fasttypes = {int, str, frozenset, type(None)},, referer: http://192.168.30.17/logistics/alarms/
[Wed Sep 21 17:07:54 2016] [error] [client 192.168.30.93] ^, referer: http://192.168.30.17/logistics/alarms/
[Wed Sep 21 17:07:54 2016] [error] [client 192.168.30.93] SyntaxError: invalid syntax, referer: http://192.168.30.17/logistics/alarms/
wsgi.py
# Add the site-packages of the chosen virtualenv to work with
site.addsitedir('/new_esmart/esmart_env/lib/python2.7/site-packages')
# Add the app's directory to the PYTHONPATH
sys.path.append('/new_esmart/esmart2')
sys.path.append('/new_esmart/esmart2/esmart2')
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "esmart2.settings")
# Activate your virtual env
activate_env = os.path.expanduser("/new_esmart/esmart_env/bin/activate_this.py")
execfile(activate_env, dict(__file__=activate_env))
application = django.core.handlers.wsgi.WSGIHandler()
httpd.conf
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot /new_esmart/esmart2
ServerName logistica.org
ServerAlias www.logistica.org
WSGIScriptAlias//new_esmart/esmart2/esmart2/wsgi.py
ErrorLog logs/logistica.org-error_log
CustomLog logs/logistica.org-access_log common
</VirtualHost>
WSGIPythonPath /new_esmart/esmart2:/new_esmart/esmart_env/lib/python2.7/site-packages
/etc/httpd/conf.d/wsgi.conf
LoadModule wsgi_module modules/mod_wsgi.so
Хотя вы добавили каталог библиотек 2.7 в путь Python, на самом деле вы не используете версию Python версии 2.7. Здесь много вопросов (большинство из них отвечает автор mod_wsgi), которые рассказывают вам, как указать его на другую версию. –
Не связанный с вашей текущей проблемой, но в новых версиях Django вам нужно [использовать 'get_wsgi_application()'] (https://docs.djangoproject.com/en/1.10/releases/1.7/#wsgi-scripts) вместо ' WSGIHandler() '. – knbk
@ DanielRoseman на моем сервере У меня такая же версия Python (2.7.8) как в env, так и в virtualenv –