[英]Apache2.2:ImportError: No module named site
Apache2 error.log:
[Thu Dec 17 18:58:33 2015] [warn] mod_wsgi: Compiled for Python/2.7.2+.
[Thu Dec 17 18:58:33 2015] [warn] mod_wsgi: Runtime using Python/2.7.3.
[Thu Dec 17 18:58:33 2015] [notice] Apache/2.2.22 (Ubuntu) mod_ssl/2.2.22 OpenSSL/1.0.1 mod_wsgi/3.3 Python/2.7.3 configured -- resuming normal operations
ImportError: No module named site
我的python版本:
python --version
Python 2.7.5
Apache2配置:
WSGIPythonHome /opt/pkgs
我可以导入网站:
me@localhost:/opt/pkgs/python/bin$ python
Python 2.7.5 (default, Aug 21 2015, 20:17:51)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import site
>>>
me@localhost:/opt/pkgs/python/bin$ python2.7
Python 2.7.3 (default, Aug 1 2012, 05:14:39)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import site
>>>
如何解决这个问题??? 任何坡道都是欢迎的。 谢谢
UPDATE
site.py在/opt/pkgs/python/lib/python2.7中。如何设置WSGIPythonHome?
为什么“ WSGIPythonHome / usr”对我有用???
对于那些因为与您一样的问题而无休止地踏上这个问题的人(例如我):
ImportError: No module named site
在apache的error.log(/var/log/apache2/error.log)中
很可能您有WSGIPythonHome
指向其他(大概)Python位置。 默认设置为:
WSGIPythonHome /usr
人们忘记提及的是它应该在的位置:
/etc/apache2/mods-enabled/wsgi.conf
该文件通常以:
<IfModule mod_wsgi.c>
#This config file is provided to give an overview of the directives,
#which are only allowed in the 'server config' context.
#For a detailed description of all avaiable directives please read
#http://code.google.com/p/modwsgi/wiki/ConfigurationDirectives
您放置在某处:
WSGIPythonHome /usr
要么
WSGIPythonHome /usr/local
或(最佳选项)删除或注释此设置,因为/ usr假定为默认设置,并使用内置的python。
要么
更改,弄乱或修复您曾经对wsgi配置弄乱的内容(就像我在尝试使某事正常工作或崩溃而又不够了解时所做的那样;))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.