python - 属性错误 : 'module' object has no attribute 'pydebug'

标签 python python-2.6

尝试运行 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/

相关文章:

python - 如何获取 Python 导入的库的文件位置

python - 精炼Python代码以供使用(跳过重复步骤)

javascript - 使用 python selenium 在浏览器中编辑元素

python - t-SNE 在不同的机器上产生不同的结果

Python 2.7.6 Pydoop 在 Ubuntu 上安装失败

Python 2.6 如何将此字符串转换为字典?

python - 用 Plotly 绘制不同的组

python - 创建简单的一次性 Python 对象的简单方法是什么?

Python 无法打开 msvcr90.dll

python - 如何让 Popen 写入文件