dpkg: error processing /var/cache/apt/archives/python2.6-minimal_2.6.6-5ubuntu1_i386.deb (--unpack)

14,346

The error message complains that /usr/lib/python2.6/site-packages is a directory but should be a symbolic link. The most likely explanation is that you have some packages installed that do not conform with the current python packaging policy (where extra packages go into /usr/lib/python2.6/dist-packages), but instead put files in /usr/lib/python2.6/site-packages.

Run dpkg -S /usr/lib/python2.6/site-packages to see what packages you have that don't conform with the current policy. The error message incites you to report a bug against these packages.

The easy solution is to remove the offending packages.

Another possibility is that you've installed things in /usr/lib/python2.6/dist-packages without going through the deb package manager. In this case, move these things to /usr/local/lib/python2.6/dist-packages. Generally speaking, you should not install or change anything in /usr except by going through dpkg or higher-level programs that call it (apt-get, aptitude, Synaptic, ...). The exception is /usr/local, where you can do anything you like. If dpkg -S /usr/lib/python2.6/site-packages tells you that no package has installed any file under that directory, you can simply move the directory to where it should be:

mv /usr/lib/python2.6/site-packages /usr/local/lib/python2.6/dist-packages

or if the target directory already exists:

mv -i /usr/lib/python2.6/site-packages/* /usr/local/lib/python2.6/dist-packages/
rmdir /usr/lib/python2.6/site-packages

If you have old-policy packages that you want to keep installed, I think you can use the following workaround:

mkdir -p /usr/local/lib/python2.6/dist-packages
mv -i /usr/lib/python2.6/site-packages/* /usr/local/lib/python2.6/dist-packages
rmdir /usr/lib/python2.6/site-packages
ln -s /usr/local/lib/python2.6/dist-packages /usr/lib/python2.6/site-packages

If the mv commands complains that some targets already exists, this needs to be resolved on a case-by-case basis.

If you do use the workaround, be prepared for considerable confusion if you install non-deb python packages in /usr/local, as /usr/local/lib/python2.6/dist-packages will contain some files managed by dpkg. Also I'm not completely sure that this won't cause any package management trouble down the line, such as errors if you later upgrade or remove the offending packages. Attempt the workaround only if you're prepared to have to do more troubleshooting later. Again, the safe option is to remove the offending packages before upgrading your python package.

Share:
14,346

Related videos on Youtube

Honza Hála
Author by

Honza Hála

Updated on September 17, 2022

Comments

  • Honza Hála
    Honza Hála over 1 year

    I had an issue (Question 199582) which was resolved. Unfortunately I am stuck at this point now.

    Running

    root@X100e:/var/cache/apt/archives# apt-get dist-upgrade 
    Reading package lists... Done
    Building dependency tree       
    Reading state information... Done
    Calculating upgrade... Done
    The following NEW packages will be installed:
      file libexpat1 libmagic1 libreadline6 libsqlite3-0 mime-support python python-minimal python2.6 python2.6-minimal readline-common
    0 upgraded, 11 newly installed, 0 to remove and 0 not upgraded.
    Need to get 0B/5,204kB of archives.
    After this operation, 19.7MB of additional disk space will be used.
    Do you want to continue [Y/n]? Y
    (Reading database ... 6108 files and directories currently installed.)
    Unpacking python2.6-minimal (from .../python2.6-minimal_2.6.6-5ubuntu1_i386.deb) ...
    new installation of python2.6-minimal; /usr/lib/python2.6/site-packages is a directory
    which is expected a symlink to /usr/local/lib/python2.6/dist-packages.
    please find the package shipping files in /usr/lib/python2.6/site-packages and
    file a bug report to ship these in /usr/lib/python2.6/dist-packages instead
    aborting installation of python2.6-minimal
    dpkg: error processing /var/cache/apt/archives/python2.6-minimal_2.6.6-5ubuntu1_i386.deb (--unpack):
     subprocess new pre-installation script returned error exit status 1
    Errors were encountered while processing:
     /var/cache/apt/archives/python2.6-minimal_2.6.6-5ubuntu1_i386.deb
    E: Sub-process /usr/bin/dpkg returned an error code (1)
    

    results in above error.

    Running

    root@X100e:/var/cache/apt/archives# dpkg -i python2.6-minimal_2.6.6-5ubuntu1_i386.deb 
    (Reading database ... 6108 files and directories currently installed.)
    Unpacking python2.6-minimal (from python2.6-minimal_2.6.6-5ubuntu1_i386.deb) ...
    new installation of python2.6-minimal; /usr/lib/python2.6/site-packages is a directory
    which is expected a symlink to /usr/local/lib/python2.6/dist-packages.
    please find the package shipping files in /usr/lib/python2.6/site-packages and
    file a bug report to ship these in /usr/lib/python2.6/dist-packages instead
    aborting installation of python2.6-minimal
    dpkg: error processing python2.6-minimal_2.6.6-5ubuntu1_i386.deb (--install):
     subprocess new pre-installation script returned error exit status 1
    Errors were encountered while processing:
     python2.6-minimal_2.6.6-5ubuntu1_i386.deb
    

    results in above error.

    Running

    root@X100e:/var/cache/apt/archives# dpkg -i --force-depends python2.6-minimal_2.6.6-5ubuntu1_i386.deb 
    (Reading database ... 6108 files and directories currently installed.)
    Unpacking python2.6-minimal (from python2.6-minimal_2.6.6-5ubuntu1_i386.deb) ...
    new installation of python2.6-minimal; /usr/lib/python2.6/site-packages is a directory
    which is expected a symlink to /usr/local/lib/python2.6/dist-packages.
    please find the package shipping files in /usr/lib/python2.6/site-packages and
    file a bug report to ship these in /usr/lib/python2.6/dist-packages instead
    aborting installation of python2.6-minimal
    dpkg: error processing python2.6-minimal_2.6.6-5ubuntu1_i386.deb (--install):
     subprocess new pre-installation script returned error exit status 1
    Errors were encountered while processing:
     python2.6-minimal_2.6.6-5ubuntu1_i386.deb
    

    is not able to fix this.

    Any clues how to fix this?

  • Honza Hála
    Honza Hála over 13 years
    thanks Gilles, unfortunately running dpkg -S /usr/lib/python2.6/site-packages/ returns an error. note: there is no deb package in here (maybe that's the reason?) -> I prefer the easy solution ;) -> do you intend a apt-get remove/purge python2.6?
  • Gilles 'SO- stop being evil'
    Gilles 'SO- stop being evil' over 13 years
    @udo: Sorry, I goofed, run dpkg -S /usr/lib/python2.6/site-packages (no trailing slash). If the directory is empty, just remove it. Otherwise, what does it contain?
  • Honza Hála
    Honza Hála over 13 years
    no prob, tried both... the dir contains file git_remote_helpers-0.1.0-py2.6.egg-info and dir git_remote_helpers -> guess I can delete /usr/lib/python2.6/site-packages/* -> correct?
  • Gilles 'SO- stop being evil'
    Gilles 'SO- stop being evil' over 13 years
    @udo: If these are python packages you installed manually (i.e. they're python packages, but not dpkg packages), they should be in /usr/local/lib/python2.6/dist-packages. You can just move them there (see my edit).
  • Honza Hála
    Honza Hála over 13 years
    You are the man! worked! -> this is strange though, because I don't remember that I manually installed those packages... thanks a lot!