由于 python 错误,gdb 无法运行

由于 python 错误,gdb 无法运行

我正在尝试运行 gdb,但是当我按下回车键时,我收到此错误

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'

我是不是缺少了什么软件包?我有 12.04

编辑:

$ file /usr/bin/gdb
/usr/bin/gdb: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.24, BuildID[sha1]=0x8cd6c593fd6ffe6fd72266bf3d3407ea599b8143, stripped

$ dpkg -S /usr/bin/gdb
gdb: /usr/bin/gdb

答案1

StackExchange 上关于此问题的问题

GDB 使用 Python 编写脚本,但如果您构建了自己的 Python 版本,则似乎会出现问题。它会找到您的新 Python 可执行文件,但随后尝试加载系统 Python 配置,导致不匹配。这似乎是嵌入 Python 的其他应用程序中更广泛存在的问题。

答案2

快速而肮脏的解决方法,export PYTHONPATH=""仅需一次会话。链接 SE 问题不幸的是,目前还没有提供长期的解决方案。

相关内容