After doing an upgrade from 15.10 to 16.04, my Python packages seem broken. Looks like a compilation error for python-minimal.

me@me:/etc/apt/sources.list.d$ sudo apt-get -f install
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Correcting dependencies... Done
The following additional packages will be installed:
  libpython-dbg libpython-dev libpython-stdlib python
Suggested packages:
  python-doc python-tk
The following packages will be upgraded:
  libpython-dbg libpython-dev libpython-stdlib python
4 upgraded, 0 newly installed, 0 to remove and 1208 not upgraded.
5 not fully installed or removed.
Need to get 0 B/160 kB of archives.
After this operation, 113 kB disk space will be freed.
Do you want to continue? [Y/n] y
Setting up python-minimal (2.7.11-1) ...
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/runpy.py", line 162, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/local/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/usr/local/lib/python2.7/compileall.py", line 16, in <module>
    import struct
  File "/usr/local/lib/python2.7/struct.py", line 1, in <module>
    from _struct import *
ImportError: /usr/local/lib/python2.7/site-packages/_struct.so: undefined symbol: _Py_RefTotal
dpkg: error processing package python-minimal (--configure):
 subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
E: Sub-process /usr/bin/dpkg returned an error code (1)

I don't know where it came from, but I had a python binary in /usr/local/bin that was overriding my default one. It was build with an older gcc and that was causing the problem.

| improve this answer | |
  • That means you had compiled and installed Python from source in the past. – edwinksl Jul 21 '16 at 19:28

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.