Skip to content

Instantly share code, notes, and snippets.

@alastori
Last active May 26, 2022 17:44
Show Gist options
  • Save alastori/45e66b872e567ee9afcff071fbe483d6 to your computer and use it in GitHub Desktop.
Save alastori/45e66b872e567ee9afcff071fbe483d6 to your computer and use it in GitHub Desktop.
Python 3 virtual environment

Create a new Python Virtual Environment

Pre-requistes

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
$ cd $VENVDIR
$ ls 
README.md 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 https://files.pythonhosted.org/packages/9b/e6/aa8149e048eda381f2a433599be9b1f5e5e3a189636cd6cf9614aa2ff5be/pip-22.1.1-py3-none-any.whl (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