0

So I just installed the latest version of python, and I also changed the old 3.5 python version to 3.10 in my environment variables. There is no python 3.5 in the PATH inside environment variables, but when I run py --version in my CMD then it says version 3.5, but when I type python --version then it says version 3.10.2, is there a way to manually choose which version should be called on py or python?

version prints

The Mungax
  • 35
  • 2
  • 9
  • 1
    Assuming you're on Windows, what does `where python` give you? What about `where py`? Alternatively for linux, `which python` and `which py`. – Axe319 Jan 20 '22 at 10:45
  • [This question](https://stackoverflow.com/q/50896496/4177009) looks relevant. – Ture Pålsson Jan 20 '22 at 10:46
  • @TheMungax [This](https://learn.microsoft.com/en-us/answers/questions/263980/switching-between-versions-of-python-installed-fro.html) seems to be exactly what you're looking for. Specifically `py -3.10`. – Axe319 Jan 20 '22 at 10:58

2 Answers2

0

You would need a python virtual environment to control it. (venv)

Just one thing, you can create a venv only with the version or python which is installed.

Also you can use conda to manage different version of python.

Here is a tutorial to create a venv or use conda on windows :

https://medium.com/co-learning-lounge/create-virtual-environment-python-windows-2021-d947c3a3ca78#a904

vinalti
  • 966
  • 5
  • 26
  • So I just have to do the following in the python310 folder where I in CMD do: (1) `python -m venv virtual_env`, then (2) `.\virtual_env\Scripts\activate`, then the python version is set to be `3.10.2` when I run `py --version` or `python --version`? – The Mungax Jan 20 '22 at 10:50
0

@The Mungax I am not sure but I can show you something that might help you what is the Difference between “python” vs “py”

PYTHON

The command python refers to the Python executable of the default Python installation. Technically, the path of this version is stored inside the PATH environment variable where your OS will search for the executable when processing any command.

PY

The command py refers to the Python launcher, a utility that’s automatically installed into C:\Windows\ for any Python installation on Windows. All files in the Windows folder are accessible without needing to modify the PATH environment variable. Thus, the Python launcher automatically delegates the work to the latest Python version installed in your environment. However, you can also specify the used installation by means of a flag argument such as in py -3.6 to specify Python version 3.6.

Saurhub
  • 1
  • 3