Contents

Pipvenvcreation

Create the environment from cmd

1
2
3
4
python -m venv /path/to/new/virtual/environment

# generally I use:
python -m venv env

Then activate it:

1
2
3
4
/path/to/new/virtual/environment/Scripts/activate.bat

# windows uses backslashes...
\env\Scripts\activate.bat 

Select specific python version

In the cmd prompt, use the following to get the correct python version:

1
py -3.11

Then the rest follows as normal.

Command explanation

In Python, the -m flag is used to run a module as a script. When you run python -m module_name, Python searches for the specified module in the module search path (sys.path), imports it, and then runs it as the __main__ module.

1
python -m my_module

Install from requirements

After environment activation:

1
2
3
pip install -r /path/to/requirements.txt

pip install -r requirements.txt