How to maintain your python installation

My question is generally related to the handling of Python and system upgrades.
After a system upgrade I had to reinstall all my python packages in the virtual environment.

As I understand it, virtual environments are meant to allow you to use different versions of python and python packages for different projects.

I have a few questions about venv/Python under Garuda Linux:

  • The arch linux docs [here] (Python/Virtual environment - ArchWiki) states that virtual environments use system python per default, if no version is given explicitly. So even though I get a different path when entering the command which python in the environment, the path still points to the system-wide python installation? I created my venv using this command:
virtualenv myenv
  • I assume that if there is a system upgrade, the python version will be upgraded too and therefore also the ‘version’ in the venv?
  • Can I prevent this upgrade of the python version in the venv by specifying a python version for the venv explicitly during its creation?
  • As far as I understand it, python packages should be installed via pacman and not via pip. If you install something with pip, then this should be done in an environment. Isn’t it then the case that these packages should not be changed during a system upgrade? (But I assume this does not apply if the venv python is the same as the system-wide python)?

Sorry for bothering you with this problem, I just want to do it the right way and I am a bit confused right now.

I wish you all a happy new year!

I think you can specify python version for the environement like

python -m venv /path/to/env/
python3 -m venv /path/to/env/
python3.1 -m venv /path/to/env/

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.