python-3.xinstallationpiplinux-mint-20

Is it possible to install a pip/pip3 specific to python3.9 and keep the pip for python3.8?


I am on Linux Mint 20.3 Una. My environment contains already a pip, used by python3.8:

$ pip --version
pip 20.0.2 from /usr/lib/python3/dist-packages/pip (python 3.8)

python3 links to python3.8

$ ls -l /usr/bin/python3
/usr/bin/python3 -> python3.8

I have python3.9 installed. I want to install a pip/pip3 specific to python3.9. It may install files in /usr/lib/python3.9/dist-packages/pip or pip3 or wherever it wants to, as long as both pip's are fully compartmented.

Is it possible to do so?

I read answers on stackoverflow and similar websites to questions that are very close to mine, but the answers vary significantly : use repo deadsnakes, download pip-script.py, run python3.9 -m pip install pip, etc.

Which solution is the best?

I did not try anything. I do not want to break my installation of python. Yesterday I installed python3.9 then set it as default, and today I had to revert python3 to python3.8 because my cinnamon was badly broken with python3.9 (no Terminal, no internet, no taskbar, no menu button), with all the panic inherent to seeing the machine becoming completely cripled.

I can still backup the folder

/usr/lib/python3/dist-packages/pip

Would it be enough of a safety net to revert any mistake made on pip?

It makes me feel like walking on eggs, with steel shoes.

I want to keep untouched the pip packages that are used by Linux Mint with python3.8.


Solution

  • Sorry for the late response, but I put this Python problem in pause for quite a bit of time.

    Eventually answering my own question:

    Thanks to Berkay Gökmen for the detailed and nicely formatted answer, but when I begun going through these steps, I feared that these installations would temper with Linux Mint.

    I do not recall precisely but at one of the steps, a python command meant for python3.9 would have happened with python3.8, the version of Python that is used by Linux Mint and which should not be tempered at all with.

    In any case, I simply accepted the fact that the Python installed on Linux Mint is meant for the distro and not for me, the User.

    If I wanted to use Python, I should use virtual environments.

    Thus I chose to install pyenv and venv (virtual environment) for pyenv. I followed these instructions: https://forums.linuxmint.com/viewtopic.php?t=362499 and the instructions directly given by the packages concerned: pyenv and venv.

    It is sad that Linux Mint simply takes control of Python on a machine, instead of using its own dedicated environment and leaving the global Python to the User. I think this breaks one of the mantras of Linux by putting the Operating System in the first place before the User.