mod_wsgi + python 2.7.5导入错误

时间:2013-06-19 12:11:35

标签: python-2.7 apache2 mod-wsgi

我安装了可能正确的apache2,mod_wsgi和python 2.7.5。问题是127.0.0.1没有打开(加载只是冻结),我看到以下登录错误.log:

    [Wed Jun 19 14:49:11 2013] [notice] Apache/2.2.22 (Ubuntu) mod_wsgi/3.4 Python/2.7.3 configured -- resuming normal operations
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/site.py", line 548, in <module>
    main()
  File "/usr/local/lib/python2.7/site.py", line 530, in main
    known_paths = addusersitepackages(known_paths)
  File "/usr/local/lib/python2.7/site.py", line 266, in addusersitepackages
    user_site = getusersitepackages()
  File "/usr/local/lib/python2.7/site.py", line 241, in getusersitepackages
    user_base = getuserbase() # this will also set USER_BASE
  File "/usr/local/lib/python2.7/site.py", line 231, in getuserbase
    USER_BASE = get_config_var('userbase')
  File "/usr/local/lib/python2.7/sysconfig.py", line 516, in get_config_var
    return get_config_vars().get(name)
  File "/usr/local/lib/python2.7/sysconfig.py", line 449, in get_config_vars
    import re
  File "/usr/local/lib/python2.7/re.py", line 105, in <module>
    import sre_compile
  File "/usr/local/lib/python2.7/sre_compile.py", line 14, in <module>
    import sre_parse
  File "/usr/local/lib/python2.7/sre_parse.py", line 17, in <module>
    from sre_constants import *
  File "/usr/local/lib/python2.7/sre_constants.py", line 18, in <module>
    from _sre import MAXREPEAT
ImportError: cannot import name MAXREPEAT  

尝试重新启动apache,但它无法正常工作。谢谢你的帮助!

1 个答案:

答案 0 :(得分:2)

刚刚找到解决方案。我在我的python的解释器中检查了'sys.prefix'并打印了'/ usr / local',但是我没有在apache配置中设置WSGIPythonHome(在本案例中用mod_wsgi docs编写)。只是为了实验我设置'WSGIPythonHome / usr'。这很奇怪,但它解决了我的问题,现在一切都很好!