在apache2 下部署django 出现问题(使用conda虚拟环境)

使用python3, conf 如下

<VirtualHost *:5060>
    ServerName localhost:5060
    ServerAdmin Ysdd1@163.com

    # WSGIPythonPath /home/yangtz/anaconda3/lib/python3.6/site-packages
    WSGIDaemonProcess 192.168.100.18 python-path=/data2/serverend/dpsplat python-home=/home/yangtz/anaconda3/envs/keshihua/lib/python3.6/site-packages
    WSGIProcessGroup 192.168.100.18
    WSGIScriptAlias / /data2/serverend/dpsplat/visualplat/wsgi.py



    <Directory /data2/serverend/dpsplat/visualplat>
    <Files wsgi.py>
        Require all granted
    </Files>
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/error-dpsplat.log
    CustomLog ${APACHE_LOG_DIR}/access-dpsplat.log combined

</VirtualHost>

django项目所需的环境在conda的虚拟环境中,命名为keshihua
mod_wsgi.so 已经load了,确认是python3的

apache2正常启动,但是链接没反应,错误日志如下:

[Wed Aug 02 13:31:51.550060 2017] [wsgi:error] [pid 27945:tid 140279756412672] [remote 192.168.100.20:43891] mod_wsgi (pid=27945): Target WSGI script '/data2/serverend/dpsplat/visualplat/wsgi.py' cannot be loaded as Python module.
[Wed Aug 02 13:31:51.550132 2017] [wsgi:error] [pid 27945:tid 140279756412672] [remote 192.168.100.20:43891] mod_wsgi (pid=27945): Exception occurred processing WSGI script '/data2/serverend/dpsplat/visualplat/wsgi.py'.
[Wed Aug 02 13:31:51.550799 2017] [wsgi:error] [pid 27945:tid 140279756412672] [remote 192.168.100.20:43891] Traceback (most recent call last):
[Wed Aug 02 13:31:51.550837 2017] [wsgi:error] [pid 27945:tid 140279756412672] [remote 192.168.100.20:43891]   File "/data2/serverend/dpsplat/visualplat/wsgi.py", line 13, in <module>
[Wed Aug 02 13:31:51.550844 2017] [wsgi:error] [pid 27945:tid 140279756412672] [remote 192.168.100.20:43891]     from django.core.wsgi import get_wsgi_application
[Wed Aug 02 13:31:51.550867 2017] [wsgi:error] [pid 27945:tid 140279756412672] [remote 192.168.100.20:43891] ImportError: No module named 'django'
[Wed Aug 02 13:31:52.549949 2017] [wsgi:error] [pid 27945:tid 140279638914816] [remote 192.168.100.20:43379] mod_wsgi (pid=27945): Target WSGI script '/data2/serverend/dpsplat/visualplat/wsgi.py' cannot be loaded as Python module.
[Wed Aug 02 13:31:52.550040 2017] [wsgi:error] [pid 27945:tid 140279638914816] [remote 192.168.100.20:43379] mod_wsgi (pid=27945): Exception occurred processing WSGI script '/data2/serverend/dpsplat/visualplat/wsgi.py'.
[Wed Aug 02 13:31:52.550199 2017] [wsgi:error] [pid 27945:tid 140279638914816] [remote 192.168.100.20:43379] Traceback (most recent call last):
[Wed Aug 02 13:31:52.550243 2017] [wsgi:error] [pid 27945:tid 140279638914816] [remote 192.168.100.20:43379]   File "/data2/serverend/dpsplat/visualplat/wsgi.py", line 13, in <module>
[Wed Aug 02 13:31:52.550252 2017] [wsgi:error] [pid 27945:tid 140279638914816] [remote 192.168.100.20:43379]     from django.core.wsgi import get_wsgi_application
[Wed Aug 02 13:31:52.550285 2017] [wsgi:error] [pid 27945:tid 140279638914816] [remote 192.168.100.20:43379] ImportError: No module named 'django'

这是怎么回事?我明明在conf里指定conda 环境了啊!!!

阅读 5.3k
2 个回答
在服务器运行一下python看看是不是在adconda下
如果是则import django看看
如果不是,则需要软链python到你的adconda下的python

ImportError: No module named 'django'问题不是很明显么?

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题