【问题标题】:AttributeError: 'module' object has no attribute 'pydebug' on dreamhost after server updateAttributeError:“模块”对象在服务器更新后在 Dreamhost 上没有属性“pydebug”
【发布时间】:2014-10-15 14:47:57
【问题描述】:

我在具有自定义安装 python 的 Dreamhost 共享服务器上遇到此错误。几个月前我使用this tutorial 进行安装:

本周末更新dreamhost的服务器(到ubuntu 12.04)后,出现了这个错误:

Traceback (most recent call last):
  File "/usr/lib/python2.7/site.py", line 562, in <module>
    main()
  File "/usr/lib/python2.7/site.py", line 544, in main
    known_paths = addusersitepackages(known_paths)
  File "/usr/lib/python2.7/site.py", line 271, in addusersitepackages
    user_site = getusersitepackages()
  File "/usr/lib/python2.7/site.py", line 246, in getusersitepackages
    user_base = getuserbase() # this will also set USER_BASE
  File "/usr/lib/python2.7/site.py", line 236, in getuserbase
    USER_BASE = get_config_var('userbase')
  File "/usr/lib/python2.7/sysconfig.py", line 577, in get_config_var
    return get_config_vars().get(name)
  File "/usr/lib/python2.7/sysconfig.py", line 476, in get_config_vars
    _init_posix(_CONFIG_VARS)
  File "/usr/lib/python2.7/sysconfig.py", line 337, in _init_posix
    makefile = _get_makefile_filename()
  File "/usr/lib/python2.7/sysconfig.py", line 331, in _get_makefile_filename
    return os.path.join(get_path('platstdlib').replace("/usr/local","/usr",1), "config" + (sys.pydebug and "_d" or ""), "Makefile")
AttributeError: 'module' object has no attribute 'pydebug'

我尝试了这些方法,但没有成功:

  • 重新安装自定义 python
  • 更改 PYTHONPATH
  • 在dreamhost中创建一个新用户,重新开始
  • 在没有自定义 python 的情况下安装 virtualenv。

我认为问题出在python的路径上,但我不知道如何改变它。

编辑 1:我尝试在 ./configure 命令上使用 --with-pydebug 安装自定义 python。没用。

【问题讨论】:

标签: python django passenger wsgi dreamhost


【解决方案1】:

只需在文件中放入passenger_wsgi.py这几行

INTERP = cwd + "/env/bin/python"
if sys.executable != INTERP: 
    os.execl(INTERP, INTERP, *sys.argv)

而不是

#Switch to new python
if sys.version < "2.7.7": os.execl(cwd+"/env/bin/python", "python2.7", *sys.argv)

这会强制 passenger_wsgi.py 使用安装在 virtualenv 中的 python 解释器。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-11-18
    相关资源
    最近更新 更多