Skip to content

Instantly share code, notes, and snippets.

Last active May 26, 2022
What would you like to do?
Python 3 virtual environment

Create a new Python Virtual Environment


Define the directory

$ export VENVDIR=~/test-python

Check if Python 3 is installed

$ python3 --version
Python 3.8.3

Create Python Virtual Environment

$ python3 -m venv $VENVDIR
$ ls bin   include   lib   pyvenv.cfg

Activate Python Virtual Environment

$ source $VENVDIR/bin/activate
$ python --version
Python 3.8.3

Upgrade Python pip

With the VirtualEnv activated:

$ python -m pip install --upgrade pip
Collecting pip
  Downloading (2.1MB)
     |████████████████████████████████| 2.2MB 4.4MB/s 
Installing collected packages: pip
  Found existing installation: pip 19.2.3
    Uninstalling pip-19.2.3:
      Successfully uninstalled pip-19.2.3
Successfully installed pip-22.1.1

$ pip --version
pip 22.1.1 from .../lib/python3.8/site-packages/pip (python 3.8)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment