Set up a Python virtual environment

From Parallel Library Services
Revision as of 21:46, 2 November 2021 by Simon (talk | contribs) (Created page with "Python virtual environments run their own site directories, allowing them to be optionally separated from system directories. This can easily avoid a potential nightmare of ve...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Python virtual environments run their own site directories, allowing them to be optionally separated from system directories. This can easily avoid a potential nightmare of version conflicts - one piece of software on your system may require a certain version to run, while another make require a different one.

Creating the virtual environment

venv is a tool that can be used to create an environment:

python3 -m venv venv

To activate the virtual environment, run:

source venv/bin/activate

You will see the prompt change to something like this:

(venv)Username@Computer myfolder %

To close it, simply type

exit