pyenv Virtual Enviroments (venv) - adeemacdowell/adeemacdowell.github.io GitHub Wiki
Install Instructions
https://realpython.com/intro-to-pyenv/
sudo apt-get update
dependencies
sudo apt-get install -y make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev xz-utils tk-dev libffi-dev liblzma-dev python-openssl
install pyenv
curl https://pyenv.run | bash
Preview your PATH
echo $PATH (see the path)
Load pyenv automatically by adding the following to ~/.bashrc:
export PATH="/home/adee/.pyenv/bin:$PATH"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
open and close terminal
echo $PATH (see pyenv at start of path)
see versions
pyenv versions (lists the system version)
install another version
pyenv install 3.7.2
pyenv versions (see 2nd ver listed)
make the new ver the system ver
pyenv global 3.7.2
pyenv versions (see the * next to the new one)
Basic Commands
pyenv versions (show all versions of python available)
pyenv install x.x.x (add a version to pyenv)
pyenv update (get the latest py versions)
pyenv activate xxx (activate a virtual environment)
pyenv uninstall 2.7.15
pyenv global 3.6.8 (set the system python)
pyenv local x.x.x (set a python ver for a particular folder)
pyenv shell 3.8-dev (what ver to use in the shell)
pyenv virtualenv <python_version> <environment_name> (creates a venv)
pyenv local <environment_name> (switches to venv)
pyenv local system (exit a venv)
python --version (get py version of venv)
--version
*activate
commands
completions
deactivate
doctor
exec
*global
*help
hooks
init
*install
installer
*local
offline-installer
prefix
rehash
root
shell
shims
*uninstall
update
*version
version-file
version-file-read
version-file-write
version-name
version-origin
*versions
*virtualenv
virtualenv-delete
virtualenv-init
virtualenv-prefix
virtualenvs
whence
which
Pyenv and pycharm
from inside the new venv:
pip install pip-tools
pip-sync requirements/core.txt requirements/dev.txt
Install the new python version
$ pyenv install 3.9.9
$ deactivate
Create a new venv
$ pyenv virtualenv 3.9.9 venv399
Make sure it created, look here
usr/adee/.pyenv/versions
In pycharm, create a new venv and point the 'base interperator' to python in the new venv:
usr/adee/.pyenv/versions/venv399/bin/python38
Make sure the venv in pycharm is named the same as the new venv
Switch to the new venv and run pip freeze