- Install PyEnv (see also here: https://github.com/pyenv/pyenv-installer)
- Requires GIT
- Install with
curl https://pyenv.run | bash
- Add following lines to
vi ~/.bashrc
:
export PYENV_ROOT="$HOME/.pyenv"
command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"
- Install Python 3.9 using
pyenv install 3.9.13
- Create Virtual Environment with Python 3.9.13 using
pyenv virtualenv 3.9.13 projectx
- Activate environment for current folder using
pyenv local projectx
- this creates a file
.python-version
containing the python environment name
- this creates a file
If you get warnings when installing Python 3.9.13, as shown in following example, you need to install some missing system libraries:
Downloading Python-3.9.13.tar.xz...
-> https://www.python.org/ftp/python/3.9.13/Python-3.9.13.tar.xz
Installing Python-3.9.13...
WARNING: The Python bz2 extension was not compiled. Missing the bzip2 lib?
WARNING: The Python curses extension was not compiled. Missing the ncurses lib?
WARNING: The Python ctypes extension was not compiled. Missing the libffi lib?
WARNING: The Python readline extension was not compiled. Missing the GNU readline lib?
WARNING: The Python sqlite3 extension was not compiled. Missing the SQLite3 lib?
WARNING: The Python lzma extension was not compiled. Missing the lzma lib?
Installed Python-3.9.13 to /home/thozub/.pyenv/versions/3.9.13
- Run
sudo apt-get update
- Run
sudo apt-get install make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev
sudo apt-get update
sudo apt-get -y install sqlite3 libsqlite3-dev libsqlite3-mod-spatialite
env PYTHON_CONFIGURE_OPTS="--enable-loadable-sqlite-extensions" \
pyenv install 3.9.13
pyenv virtualenv 3.9.13 projectx
pyenv local projectx
pyenv activate projectx