Friday, 1 May 2020

Create python virtual environment

It may not be possible for one Python installation to meet the requirements of every application, as applications will sometimes need a specific version of a library.

So, how can we use different versions of python for different applications?

The solution for this problem is to create a virtual environment, a self-contained directory tree that contains a Python installation for a specific version of Python, and other additional packages needed by the application itself.

If you're using python3:

python3 -m pip install --user virtualenv

Create virtual environment:

python3 -m venv venv

Activate it:

source venv/bin/activate

Then try:

which python

If everything is ok, you should get:

.../venv/bin/python



No comments:

Post a Comment