python 3.10 venv launches 3.9 intepreter

Viewed 633

I have just installed python3.10-full in Debian bookworm alongside 3.9, because I'd like to test an application with the newer python version. So I am creating a virtual environment running:

$ python3.10 -m venv threeten

After activating the venv, python --version returns Python 3.9.9 while python3 --version returns Python 3.10.1

If I list the venv bin directory I get:

(threeten) $ ls -l threeten/bin/ | grep python
lrwxrwxrwx 1 es es   10 Dec 23 09:58 python -> python3.10
lrwxrwxrwx 1 es es   10 Dec 23 09:58 python3 -> python3.10
lrwxrwxrwx 1 es es   19 Dec 23 09:58 python3.10 -> /usr/bin/python3.10

and:

(threeten) $ which python 
/home/es/threeten/bin/python

I tried relinking threeten/bin/python to /usr/bin/python3.10 with no success.

Is anyone experiencing the same problem? Am I doing something wrong? Thank you!

1 Answers

I am not very sure about this, but there might be a few solutions.

  1. The command you ran for creating the venv, is there supposed to be a "."? I always used python -m venv .

2.Try editing the system environment variables. I run on windows, and there you can edit system environment variables. What I would do is go to both the user and system variable's "path" variable, and select the 2 python 3.10 paths, and by "move up" get them above 3.9. That gave 3.10 the priority and thus in writing "python", it meant 3.10 and not 3.9. There must be some similar alternative for debian.

  1. I do not have much experience with linux, but considering that environment variables exist, make sure python 3.10 has a higher priority than 3.9, make the venv with python3 -m (not python 3.10) and check the version.

  2. If none of the above work, simply retry creating the venv but with python3 -m and not python 3.10. This should work because when you write python3 --version, it says 3.10. Also make sure you have venv installed in python 3.10.

Related