Just some notes on Python's Virtual Environment

Posted on January 19, 2019 in Blog

It's been quite a long time since, I have written anything here.

Lots of things have been going on since then. But, for this one just keeping it limited to some of my python notes.

Just used Python's virtual environments, https://docs.python.org/3/tutorial/venv.html

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:

python3 -m venv tutorial-env

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:

tutorial-env\Scripts\activate.bat

On Unix or MacOS, run:

source tutorial-env/bin/activate

Just to check if everything is going on fine,

run python (within the venv)

Then,

import sys
sys.path

The output should show the paths.