I am trying to run gdb, but as soon as I hit enter I get this error

Traceback (most recent call last):
  File "/usr/lib/python2.7/site.py", line 562, in <module>
  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
  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'

am I missing some package? I have 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
  • Same problem here, but no luck yet! – Greg Jan 30 '13 at 12:34
  • What's the actual command you're running? – Ken Kinder Feb 1 '13 at 20:04
  • @Ken: just gdb – Stefano Borini Feb 1 '13 at 22:55
  • Since gdb isn't a Python app, that's a little confusing. Can you run which gdb then on the file it outputs, try dpkg -S <file>> – Ken Kinder Feb 11 '13 at 0:59
  • @Ken: added info – Stefano Borini Feb 11 '13 at 10:47

See StackExchange question on this issue.

GDB uses python for scripting, but appears to have problems if you have built your own version of python. It finds your new python executable, but then tries to load the system python configuration, causing a mismatch. This seems to be a problem that applies more widely to other applications that embed python.

  • 2
    good point indeed. I have a custom python, and that could be the cause, but now the question is how can I tell gdb not to use python at all, or to use the system python. – Stefano Borini Feb 12 '13 at 3:23
  • In particular, the error is raised for Python built with --enable-shared when LD_LIBRARY_PATH includes that Python's lib directory. – Ioannis Filippidis Jan 28 '18 at 8:36

Quick and dirty work-around, export PYTHONPATH="" for just one session. Linked SE question unfortunately gives no long term solutions yet.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.