11

I am just trying to run my normal update/upgrade and have been getting this error:

dpkg: warning: files list file for package 'libpython3.7-minimal:amd64' missing; assuming package has no files currently installed
(Reading database ... 141307 files and directories currently installed.)
Preparing to unpack .../libpython3.7-stdlib_3.7.13-1+focal3_amd64.deb ...
Unpacking libpython3.7-stdlib:amd64 (3.7.13-1+focal3) ...
dpkg: error processing archive /var/cache/apt/archives/libpython3.7-stdlib_3.7.13-1+focal3_amd64.deb (--unpack):
 trying to overwrite '/usr/lib/python3.7/distutils/__init__.py', which is also in package python3.7-distutils 3.7.13-1+focal1
dpkg-deb: error: paste subprocess was killed by signal (Broken pipe)
Errors were encountered while processing:
 /var/cache/apt/archives/libpython3.7-stdlib_3.7.13-1+focal3_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

I have tried to google and look here and the solutions I have found that are recent are not working. Attempting to run Broken Fix results in:

dpkg: error processing archive /var/cache/apt/archives/libpython3.7-stdlib_3.7.13-1+focal3_amd64.deb (--unpack):
 trying to overwrite '/usr/lib/python3.7/distutils/__init__.py', which is also in package python3.7-distutils 3.7.13-1+focal1
dpkg-deb: error: paste subprocess was killed by signal (Broken pipe)
Errors were encountered while processing:
 /var/cache/apt/archives/libpython3.7-stdlib_3.7.13-1+focal3_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
karel
  • 122,292
  • 133
  • 301
  • 332

4 Answers4

17

I fixed it by removing python3.7 and its library and reinstalling it after.

This worked for me:

sudo dpkg --remove --force-remove-reinstreq python3.7 
sudo dpkg --remove --force-remove-reinstreq libpython3.7-stdlib 
sudo apt-get clean 
sudo apt-get autoremove 
sudo apt-get install python3.7
Colin
  • 13
  • 3
3

None of the previous answers worked for me, so I made I work with:

sudo apt-get remove --purge *python3.7*
sudo apt-get clean
sudo apt-get install python3.7-full

This was in the context of using Python from the deadsnakes repository.

LeandroN.
  • 131
1

Remove and Reinstalling python 3.7 works for me

sudo dpkg --remove --force-remove-reinstreq python3.7 
sudo dpkg --remove --force-remove-reinstreq libpython3.7-stdlib 
sudo apt-get clean 
sudo apt-get autoremove 
sudo apt-get install python3.7
Akitha_MJ
  • 301
0

It may be better to use Anaconda/Miniconda for non-administrative uses. You may also compile python from the source in your home folder.

sudo apt install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev wget

wget https://www.python.org/ftp/python/2.7.18/Python-2.7.18.tgz tar -xf Python-2.7.18.tgz

cd Python-2.7.18/

./configure --enable-optimizations --enable-shared --prefix=$HOME/local make -j4 make install

To use this installation add these lines into $HOME/.bashrc and source it.

export PATH=$HOME/local/bin
export LD_LIBRARY_PATH=$HOME/local/lib
export MANPATH=$HOME/local/share/man

Since different projects often use conflicting packages you may use different conda environments or use venv with your local installation

python -m venv <project_name>_env

This activate this environment use

. <project_name>_env/bin/activate

and

deactivate

to come out.