To create a virtual environment, decide upon a directory where you want to place it, and run the venv
module as a script with the directory path:
|
|
This will create the tutorial-env
directory if it doesn’t exist, and also create directories inside it containing a copy of the Python interpreter, the standard library, and various supporting files.
Once you’ve created a virtual environment, you may activate it.
On Windows, run:
|
|
On Unix or MacOS, run:
|
|
(This script is written for the bash shell. If you use the csh or fish shells, there are alternate activate.csh
and activate.fish
scripts you should use instead.)
Activating the virtual environment will change your shell’s prompt to show what virtual environment you’re using, and modify the environment so that running python
will get you that particular version and installation of Python. For example:
|
|