简体   繁体   English

CMD有两个版本python

[英]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.所以我刚刚安装了最新版本的python,我还在我的环境变量中将旧的3.5 python版本更改为3.10。 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 ?环境变量内部的 PATH 中没有 python 3.5 ,但是当我在 CMD 中运行py --version时,它会显示version 3.5 ,但是当我键入python --version时,它会显示version 3.10.2 3。手动选择应该在py or python上调用哪个版本?

版画

You would need a python virtual environment to control it.您需要一个 python 虚拟环境来控制它。 (venv) (文)

Just one thing, you can create a venv only with the version or python which is installed.只有一件事,您只能使用已安装的版本或 python 创建一个 venv。

Also you can use conda to manage different version of python.您也可以使用 conda 管理不同版本的 python。

Here is a tutorial to create a venv or use conda on windows:这是在 windows 上创建 venv 或使用 conda 的教程:

https://medium.com/co-learning-lounge/create-virtual-environment-python-windows-2021-d947c3a3ca78#a904 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” @The Mungax我不确定,但我可以向您展示一些可能对您有所帮助的东西“python”与“py”之间的区别

PYTHON PYTHON

The command python refers to the Python executable of the default Python installation.命令 python 指的是默认 Python 安装的 Python 可执行文件。 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.从技术上讲,此版本的路径存储在 PATH 环境变量中,您的操作系统将在处理任何命令时搜索可执行文件。

PY PY

The command py refers to the Python launcher, a utility that's automatically installed into C:\Windows\ for any Python installation on Windows. 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. Windows 文件夹中的所有文件都可以访问,无需修改 PATH 环境变量。 Thus, the Python launcher automatically delegates the work to the latest Python version installed in your environment.因此,Python 启动器会自动将工作委托给您的环境中安装的最新 Python 版本。 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.但是,您也可以通过标志参数来指定使用的安装,例如在 py -3.6 中指定 Python 版本 3.6。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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