简体   繁体   中英

CMD has two versions of python

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 ?

版画

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

@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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM