I needed to upgrade Python to install a package (PyMC3) requiring a version>3.5.4. I installed python 3.8.3 without any problem (installing prerequisite libraries, getting file from official repo with wget,using make altinstall, etc), but when I checked python version:
eric@debian:/$ python3 --version
Python 3.6.9 :: Anaconda, Inc.
eric@debian:~$ python3.8 --version
Python 3.8.3
(honestly, i don't remember having installed anaconda in this computer!; according to the pymc3 install error my version was 3.5.4). I tried to fix it up with update-alternatives:
eric@debian:~$ update-alternatives --config python3
There are 2 choices for the alternative python3 (providing /usr/bin/python3).
Selection Path Priority Status
------------------------------------------------------------
* 0 /usr/local/bin/python3.8 10 auto mode
1 /home/eric/anaconda2/bin/python3 2 manual mode
2 /usr/local/bin/python3.8 10 manual mode
But python3 --version continue throwing Python 3.6.9 :: Anaconda, Inc. When I tried to use pip:
eric@debian:~$ sudo pip3 pymc3
Traceback (most recent call last):
File "/usr/bin/pip3", line 9, in <module>
from pip import main
ImportError: cannot import name 'main' from 'pip' (/usr/local/lib/python3.8/site-packages/pip/__init__.py)
After reading related questions, I tried reinstalling python3-pip but it is already the newest version. I tried to uninstall it with sudo python3 -m pip uninstall pip
but it gave me a bunch of red error lines, sudo -H pip3 install --upgrade pip
didn't work either (same ImportError for name 'main'). By the way:
eric@debian:~$ which pip3 pip
/usr/bin/pip3
/home/eric/anaconda2/bin/pip
eric@debian:~$ pip --version
pip 19.3.1 from /home/eric/anaconda2/lib/python3.6/site-packages/pip (python 3.6)
eric@debian:~$ pip3 --version
Traceback (most recent call last):
File "/usr/bin/pip3", line 9, in <module>
from pip import main
ImportError: cannot import name 'main' from 'pip' (/usr/local/lib/python3.8/site-packages/pip/__init__.py)
Thanks in advance!
EDIT: After many tries with posts related to this ImportError and PATH environment, I removed Anaconda2 (which was broken) and installed Anaconda3. It works fine, but when I tried pip3 --version
:
bash: /usr/bin/pip3: /usr/bin/python3: bad interpreter: No such file or directory
(but it does exist). When I tried to remove pip3 with, for example, sudo apt remove python3-pip
:
/bin/sh: 1: /usr/bin/apt-listchanges: not found
E: Sub-process /usr/bin/apt-listchanges --apt || test $? -lt 10 returned an error code (1)
E: Failure running script /usr/bin/apt-listchanges --apt || test $? -lt 10
So I have a problem with apt
and, despite many hours reading and trying, i couldn't find a way to remove, upgrade,nor even reinstall apt.
Anyway, I guess that this question is no longer suitable for stackoverflow. I will try in superuser or something similar.