0

I am having problems installing/uninstalling things with apt. I think this is because I have unistalled python and apt is trying to use it. I have miniconda, but when I use apt it is not accessing this miniconda version. How do I make it do so?

More info:

$ ls -l /usr/bin/\*python\*  
/usr/bin/python -> /home/neiltheory/miniconda2/bin/python  
/usr/bin/python2 -> python2.7  
/usr/bin/python2.7  
/usr/bin/python3 -> /home/neiltheory/miniconda2/bin/python  
/usr/bin/python3.6  
/usr/bin/python3.6m  
/usr/bin/python3m -> python3.6m  
/usr/bin/x86_64-linux-gnu-python2.7-config  
/usr/bin/x86_64-linux-gnu-python-config -> x86_64-linux-gnu-python2.7-config  

when I do:

 sudo apt remove python3.6  

I get a bunch of dpkg errors and a suggestion to do:

apt --fix-broken install  

...which also produces a bunch of python errors.

Edit: Solution:

After re building the appropriate system pythons from source code and installing them in the same place apt and dpkg started to behave themselves again. However all was not entirely well - some of my programs which used python just didn't work 100% as they should. Specifically the terminal app terminator continually crashed and a physics program 'MadGraph' didn't function fully either. Not being a python expert and needing desperately to continue my work I nuked the lot, installed a fresh Ubuntu and vowed never to touch the system python installations again. Lesson learned, but perhaps solution not yet found.

I'm not sure of the etiquette for answering ones own question, and I'm not sure if this even constitutes an answer of if it's a further question:

QUESTION: Is there a better way of dealing with this than doing a complete reinstall?

  • v2 and v3 together would be fine. Yes, shell use python for many purposes. You should try both together. If you need python v3 for specific purpose then used like python3. – parlad neupane Sep 25 '18 at 13:55
  • The "one specific version of python" MUST be the Ubuntu-provided version. Apt and dpkg and many other essential system processes depend upon that version of Python. When you change it, you break your system...as you have discovered. – user535733 Sep 25 '18 at 14:34
3

Never change the system wide links to python to something else. This will break the dpkg package system! See also this post.

Change the python and python3 links back to the system defaults and dpkg/apt-get will start to work again.

$ sudo rm /usr/bin/python
$ sudo ln -s /usr/bin/python2.7 /usr/bin/python
$ sudo rm /usr/bin/python3
$ sudo ln -s /usr/bin/python3.6 /usr/bin/python3
  • I think I have faulty system defaults. Python2.7 makes errors when using apt to install things. This is why I have tried to do the symlinks to a miniconda python. I'm wondering if I can get dpkg/apt to use the miniconda version of python. – neiltheory Sep 25 '18 at 14:36
  • You cannot use the same Python interpreter for 2/3! If the Python interpreter inside your home is compatible to the apt/dpkg system is coincidental at best. The same goes for all the Python libraries. If you want to use custom Python interpreters, use export PATH=$PATH:/home/neiltheory/miniconda2/bin and install packages via pip in your home – Simon Sudler Sep 25 '18 at 15:00
1

The purpose of miniconda is to install a self-contained version of python. It can be python2 or python3, but this python is managed by miniconda and not apt. What is installed by apt is for the system and as others have said, you should leave them alone.

The one installed by miniconda is not located in /usr/bin/. It depends on where you installed miniconda, but if you installed it without sudo privileges, I guess it should be in ~/.conda/ somewhere.

Alternatively, you can activate miniconda using conda activate or conda activate <environment name>. Then do a which python to find it. If you need to remove these python, you can because they aren't part of the system. (But usually it is required by other packages, so I suggest you leave them alone.) Look at conda remove ....

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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