Issue
I have a Raspberry Pi 3 with Raspbian and I upgraded python version from 3.7 to 3.8. If I type python --version
in the terminal the correct version appears as the system version. However none of the modules that I have installed AFTER the version change seem to work. Python gives ModuleNotFoundError
when trying to import ANY of the modules that I have installed.
I can see the modules with pip freeze but Python seems to not be able to find them.
I followed this instructions to purge 3.7. I reinstalled pip
after purging python 3.7 but pip as again installed in /home/pi/.local/lib/python3.7/site-packages/pip
. How can I get rid of 3.7 completely?
Solution
Just to summarize the comments and suggestions from other answers:
The problem I have was caused by the fact that even I had set Python 3.8
as default and python -v
was pointing to Python 3.8
the pip script was installing modules for Python 3.7
.
The suggested solution was to use pip3.8 (or whatever version someone might have) to install packages for that equivalent Python version and that works good.
Ideally best option if someone wants to have multiple versions of python is to use pyenv. You can create multiple virtual environments with multiple python versions.
However Do not uninstall the default Python. I have also tried to uninstall the default Python 3.7
to avoid having two versions of python 3 and keeping track of which module is installed where. This was a bad idea. I did not know that many Linux distributions have applications which use the default Python. You might get a black screen and who knows what other problems see this discussion Removed Python 3 on 18.04, how can I fix my system?
Answered By - KZiovas Answer Checked By - Pedro (WPSolving Volunteer)