- do not use system python (unless to install something to get a better python)
- do not use deasnakes PPA (just system python, but with backports and older versions)
If you use one of these, you don't have a proper pip installed and you get all sorts of problems with pip & virtualenvs
do use pyenv (most convenient via install here: https://github.com/pyenv/pyenv-installer
$ curl -L https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer | bash
Check where pyenv was installed, start in your home dir
$ find . -name pyenv
./.pyenv/libexec/pyenv
./.pyenv/bin/pyenv
Then add that to your path (this should also persisted in your .bashrc - or similar)
$ export PATH=$PATH:./.pyenv/bin/pyenv
you need zlib dev headers and some more
$ sudo apt-get install -y zlib1g-dev libbz2-dev libsqlite3-dev libffi-dev libreadline-dev libssl-dev
then use pyenv to install the latest stable version, as of writing this - it is 3.9.6
$ pyenv install 3.9.6
now setup that correctly.
$ pyenv global 3.9.6
$ pyenv versions
system
* 3.9.6 (set by /home/berend/.pyenv/version)
Then check python and pip
$ pyenv which python
/home/berend/.pyenv/versions/3.9.6/bin/python
$ pyenv which pip
/home/berend/.pyenv/versions/3.9.6/bin/pip
Put the bin path into your PATH environment variable, so that python and pip are found. This should also be done in .bashrc.
$ export PATH=$PATH:~/.pyenv/bin:~/.pyenv/versions/3.9.6/bin
Now, setup virtualenv and virtualenvwrapper:
$ pip install virtualenvwrapper
and add this to your .bashrc
source ~/.pyenv/versions/3.9.6/bin/virtualenvwrapper.sh
Now check, if everything is installed properly:
$ mkvirtualenv --version