tony selcuk
tony selcuk

Reputation: 687

Commands to run different python versions on venv at once CMD

I am currently running python 3.9 on my system. Due to the incompatibility of some of python libraries like numba on python 3.9 I will have to use previous versions. 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. I have a windows 10 64 bit system, I dont use conda or anything.

CMD Output:

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

Upvotes: 0

Views: 502

Answers (1)

Niko Fohr
Niko Fohr

Reputation: 33770

In Windows you can utilize the Python Launcher for Windows. You can just install multiple Python versions from Python.org, and then use

py -3.6 -m venv venv

To create a virtual environment called "venv" (the last argument is the name). After that just activate your virtual environment and python will point to the Python 3.6 in your virtual environment.

Instead of the py launcher, you can also just use the full file path of the Python 3.6 (assuming Powershell, hence &):

& "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

Upvotes: 1

Related Questions