【发布时间】:2016-08-22 01:30:38
【问题描述】:
尝试在 Debian 7 上的 apache (2.2) 上部署 django 项目。 使用 Django 1.8 和带有 python3.4 的虚拟环境。
得到以下错误:
django.core.exceptions.ImproperlyConfigured:加载 psycopg2 模块时出错:没有名为 _psycop 的模块
这是我的 apache 配置文件。
(以下行嵌套在 VirtualHost 范围内)
#WSGI configuration for ds_monitor django project
Alias /static /home/pkaramol/Applications/timeds/ds_monitor/static_root
<Directory /home/pkaramol/Applications/timeds/ds_monitor/static_root>
Allow from all
</Directory>
<Directory /home/pkaramol/Applications/timeds/ds_monitor/ds_monitor>
<Files wsgi.py>
Allow from all
</Files>
</Directory>
WSGIDaemonProcess ds_monitor python-path=/home/pkaramol/Applications/timeds/ds_monitor:/home/pkaramol/Applications/timeds/venv_p34dj18/lib/python3.4/site-packages
WSGIProcessGroup ds_monitor
WSGIScriptAlias /ds_monitor /home/pkaramol/Applications/timeds/ds_monitor/ds_monitor/wsgi.py
这超出了 VirtualHost 范围(启用生产时虚拟环境)
WSGIPythonPath /home/pkaramol/Applications/timeds/ds_monitor:/home/pkaramol/Applications/timeds/venv_p34dj18/lib/python3.4/site-packages
另一个问题是 apache 的日志堆栈跟踪中存在以下行
File "/usr/lib/python3.2/importlib/_bootstrap.py", line 821, in _gcd_import
loader.load_module(name)
为什么要用系统的python 3.2?
在 wsgi confs 中正确指向 virtualenv 路径方面我做错了吗?
无论如何,psycopg2 模块也安装在系统中(不仅在 virtualenv 中)
【问题讨论】:
标签: django apache postgresql wsgi