Django Apache wsgi更改python版本 [英] Django Apache wsgi changes python version
问题描述
我已在具有Apache2.4.7的Ubuntu服务器上安装了Django应用,并将其配置为在虚拟环境中使用py3.5.2.
I've installed my Django app on an Ubuntu server with Apache2.4.7 and configured it to use py3.5.2 from a virtual environment.
但是,从错误中我看到的是,它从3.5开始,默认为3.4.
However, from what I can see in the errors, it's starting at 3.5 and defaulting to 3.4.
请说明为什么会这样:
/var/www/venv/lib/python3.5/site-packages
/usr/lib/python3.4
请参阅下面的完整错误:
See the full error below:
SyntaxError at /
invalid syntax (forms.py, line 2)
Request Method: GET
Request URL: http://intranet.example.com/
Django Version: 1.10.1
Exception Type: SyntaxError
Exception Value:
invalid syntax (forms.py, line 2)
Exception Location: /var/www/intranet/formater/views.py in <module>, line 7
Python Executable: /usr/bin/python3
Python Version: 3.4.3
Python Path:
['/var/www/intranet',
'/var/www/venv/lib/python3.5/site-packages',
'/usr/lib/python3.4',
'/usr/lib/python3.4/plat-x86_64-linux-gnu',
'/usr/lib/python3.4/lib-dynload',
'/usr/local/lib/python3.4/dist-packages',
'/usr/lib/python3/dist-packages',
'/var/www/intranet',
'/var/www/intranet/venv/lib/python3.5/site-packages']
这是我的apache2.conf文件:
Here's my apache2.conf file:
WSGIScriptAlias / /var/www/intranet/intranet/wsgi.py
#WSGIPythonPath /var/www/intranet/:/var/www/intranet/venv/lib/python3.5/site-packages
WSGIDaemonProcess intranet.example.com python-path=/var/www/intranet:/var/www/venv/lib/python3.5/site-packages
WSGIProcessGroup intranet.example.com
<Directory /var/www/intranet/intranet>
<Files wsgi.py>
Order deny,allow
Allow from all
</Files>
</Directory>
我在这里做什么错了?
推荐答案
Apache的mod_wsgi模块针对特定的Python版本进行了编译.您不能通过将其指向其他Python版本的Python虚拟环境来使其使用其他Python版本运行.在mod_wsgi文档中,有关使用Python虚拟环境的信息已清除:
The mod_wsgi module for Apache is compiled for a specific Python version. You cannot make it run using a different Python version by pointing it at a Python virtual environment for a different Python version. This is cleared mentioned in the mod_wsgi documentation about use of Python virtual environments at:
如果mod_wsgi是最初为Python 3.4编译的,则使mod_wsgi作为Python 3.5运行的唯一方法是卸载该版本的mod_wsgi,并构建/安装为Python 3.5编译的mod_wsgi版本.
The only way you can have mod_wsgi run as Python 3.5, if it was original compiled for Python 3.4, is to uninstall that version of mod_wsgi and build/install a version of mod_wsgi compiled for Python 3.5.
这篇关于Django Apache wsgi更改python版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!