简体   繁体   English

在 venv 上一次运行不同 python 版本的命令 CMD

[英]Commands to run different python versions on venv at once CMD

I am currently running python 3.9 on my system.我目前在我的系统上运行 python 3.9。 Due to the incompatibility of some of python libraries like numba on python 3.9 I will have to use previous versions.由于某些 python 库(如 python 3.9 上的 numba)不兼容,我将不得不使用以前的版本。 What cmd commands will I have to use to create a virtual environment so that I could run python 3.6 on cmd separate from python 3.9.我必须使用什么 cmd 命令来创建一个虚拟环境,以便我可以在 cmd 上运行 python 3.6 与 Z23EEEB43497BDD256DFC 分开。 I have a windows 10 64 bit system, I dont use conda or anything.我有一个 windows 10 64 位系统,我不使用 conda 或任何东西。

CMD Output: CMD Output:

C:\Users\maste>python -V
Python 3.9.1

In Windows you can utilize the Python Launcher for Windows .在 Windows 中,您可以将Python 启动器用于 Windows You can just install multiple Python versions from Python.org, and then use您可以从 Python.org 安装多个 Python 版本,然后使用

py -3.6 -m venv venv

To create a virtual environment called "venv" (the last argument is the name).创建一个名为“venv”的虚拟环境(最后一个参数是名称)。 After that just activate your virtual environment and python will point to the Python 3.6 in your virtual environment.之后只需激活您的虚拟环境, python将指向您的虚拟环境中的 Python 3.6。

Instead of the py launcher, you can also just use the full file path of the Python 3.6 (assuming Powershell, hence & ):除了py启动器,您还可以只使用 Python 3.6 的完整文件路径(假设 Powershell,因此& ):

& "C:\path\to\python 3.6\python.exe" -m venv venv

Lastly, you don't have to activate the virtual environment, if you don't want to.最后,如果您不想,您不必激活虚拟环境。 You can just run你可以跑

<path-to-project>\venv\Scripts\python.exe myscript.py

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

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