尝试运行 Python 脚本时,出现错误 AttributeError: 'module' object has no attribute 'pydebug'
。我正在使用 Python 2.6。
完整错误:
File "/lib/python2.6/distutils/sysconfig.py", line 238, in get_makefile_filename
return os.path.join(lib_dir, "config" + (sys.pydebug and "_d" or ""), "Makefile")
AttributeError: 'module' object has no attribute 'pydebug'
最佳答案
我尝试在自己构建的 python 上运行 Ubuntu 12.04.1 系统 gdb 时遇到了这个问题。我希望 Ubuntu 已经在系统 gdb 中构建了一些 Hook ,以便它使用 Python 的调试版本;但是钩子(Hook)不会钩住我自己的 python 中的任何东西。我通过构建自己的 gdb 并运行它来解决这个问题。
这是命令行和完整的回溯:
price@neverland:~/LSST/ip_diffim[master] $ gdb --args python tests/SnapPsfMatch.py
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(在 /usr/lib
中),尽管我告诉系统不要这样做:
price@neverland:~/LSST/ip_diffim[master] $ which python
/home/price/eups/Linux/python/2.7.2/bin/python
price@neverland:~/LSST/ip_diffim[master] $ echo $PYTHONPATH | grep usr
price@neverland:~/LSST/ip_diffim[master] $
关于python - 属性错误 : 'module' object has no attribute 'pydebug' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10641201/