11

I had several installations of python on my ubuntu 18.04 system and tried to uninstall all necessary ones and just properly reinstall python3.6

So i deleted all folders that were listed under whereis python, probably that was a bad idea.

Now if I run sudo apt-get install python3.6 it returns

Reading package lists... Done
Building dependency tree       
Reading state information... Done
python3.6 is already the newest version (3.6.5-3).
0 upgraded, 0 newly installed, 0 to remove and 4 not upgraded.
4 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] y
Setting up python3.6-minimal (3.6.5-3) ...
Could not find platform independent libraries <prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
Fatal Python error: Py_Initialize: Unable to get the locale encoding
ModuleNotFoundError: No module named 'encodings'

Current thread 0x00007f814f83c740 (most recent call first):
Aborted
dpkg: error processing package python3.6-minimal (--configure):
 installed python3.6-minimal package post-installation script subprocess returned error exit status 134
Setting up python-minimal (2.7.15~rc1-1) ...
/var/lib/dpkg/info/python-minimal.postinst: 4: /var/lib/dpkg/info/python-minimal.postinst: python2.7: not found
dpkg: error processing package python-minimal (--configure):
 installed python-minimal package post-installation script subprocess returned error exit status 127
dpkg: dependency problems prevent configuration of python3.6:
 python3.6 depends on python3.6-minimal (= 3.6.5-3); however:
  Package python3.6-minimal is not configured yet.

dpkg: error processing package python3.6 (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of python3.6-dev:
 python3.6-dev depends on python3.6 (= 3.6.5-3); however:
  Package python3.6 is not configured yet.

dpkg: error processing package python3.6-dev (--configure):
 dependency problems - leaving unconfigured
Errors were encountered while processing:
 python3.6-minimal
 python-minimal
 python3.6
 python3.6-dev
E: Sub-process /usr/bin/dpkg returned an error code (1)

I then tried to update the minimal package with sudo apt-get install -f --reinstall python3.6-minimal but that returns

Reading package lists... Done
Building dependency tree       
Reading state information... Done
0 upgraded, 0 newly installed, 1 reinstalled, 0 to remove and 4 not upgraded.
4 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
E: Internal Error, No file name for python3.6-minimal:amd64

I'm not really an experienced linux user, so I'm quite stuck here. Does someone have an idea how I can fix my python installation?

14
  • Anyone got an idea?
    – po.pe
    Aug 21, 2018 at 6:43
  • Would still be really happy if I could fix this without a complete Ubuntu re-install
    – po.pe
    Sep 8, 2018 at 15:18
  • 1
    use apt-get purge --remove <package> && apt autoremove && apt autoclean and install again your python Sep 8, 2018 at 15:21
  • and <package> would be what? Sorry I'm not really a Linux user...
    – po.pe
    Sep 8, 2018 at 15:31
  • use <package> as python3.6 Sep 8, 2018 at 15:32

2 Answers 2

11

dpkg: error processing package python3.6-minimal (--configure):
dpkg: error processing package python3.6 (--configure):
dpkg: error processing package python3.6-dev (--configure):

You have 3 dpkg package error to need reconfigure, one thing to do that follow

sudo dpkg --configure -a

i see you have 4 package not upgraded

Reading state information... Done
0 upgraded, 0 newly installed, 1 reinstalled, 0 to remove and 4 not upgraded.
4 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.

Make sure all package had been updated and upgraded, run

sudo apt-get update && sudo apt-get upgrade && sudo apt-get autoremove

if the output log said

Errors were encountered while processing:  
python3.6-minimal  
python-minimal  
python3.6  
python3.6-dev

try to type sudo apt-get install --fix-broken

if you still have error encountered while processing that package, try to purge and remove all python and reinstall it again, follow

sudo apt-get purge python* && sudo apt-get autoclean && sudo apt-get install python*

Hope this helps.

8
  • Okay, seems like I fixed it for 3.6 but not for 2.7 :(
    – po.pe
    Oct 3, 2018 at 9:47
  • what's about python2.7 ? Oct 3, 2018 at 9:48
  • When I do sudo apt-get install --fix-broken I get the same error as before but for python2.7 and python2.7-minimal respectively. I came accross this problem when I tried to install pycharm
    – po.pe
    Oct 3, 2018 at 10:01
  • @Humpawumpa I see you still have 16 apt not upgraded, make sure your apt updated/upgraded and run sudo dpkg-reconfigure python2.7* Oct 3, 2018 at 10:09
  • When I do upgrade it says 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. 2 not fully installed or removed and these two seem to be python-minimal and python2.7-minimal. For the reconfigure command it tells me that python2.7* is an illegal package name, think it doesn't like the asterix.
    – po.pe
    Oct 3, 2018 at 10:16
2

I had the same problem and was able to solve it with from here and then here . Non of the solutions with apt install or apt purge and then apt autoremove and ... worked for me unless I download them with apt download and then install them with dpkg -i. This is what worked for me:

sudo apt-get download python3 python3.6 python3-minimal python3.6-minimal libpython3.6-minimal
sudo dpkg -i *python3*.deb

Here i got an error about FileNotFoundError: [Errno 2] No such file or directory: '/usr/lib/python3.6/__phello__.foo.py' which I was able to slove it with this:

sudo apt-get download libpython3.6-stdlib
sudo dpkg -i libpython3.6-stdlib*

After this everything that depended on that default (hard to install) python3.6-minimal worked. For example I could not install ufw before this but I could after.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .