# pyenv
Pyenv enables you to manage multiple python versions on your computer. Pyenv is available only on linux and mac. There is another library called pyenv-win available for Windows.
## 1. Why pyenv?
They system python is for the system so dont mess with it
## 2. Install a new version of python
`pyenv install -v 3.8.9`
python is compiled and installed in `~/.pyenv/versions/`
```
eval "$(pyenv init -)"
```
This had to be added to the end of the .zshrc file for it to work
## 3. Uninstall
`pyenv uninstall 3.8.9`
## 4. List installed
`pyenv versions`
## 5. Which version is selected
`~/.pyenv/version` file contains the version that should be selected by default
or `pyenv versions` shows all installed versions with current version with a *
### 5.1. Global
`pyenv global 3.8.9` sets global version of python
### 5.2. Local
`pyenv local 3.8.9` selects the version of python for the folder
It adds a `.python-version` file to the folder
## 6. Shell
`pyenv shell 3.8.0` sets python version for the shell by adding some path variables
`pyenv shell --unset` unsets the shell environment
## 7. Hierarchy of selection
shell --> local --> global--> system
## 8. Virtual environments
`pyenv virtualenv 3.8.9 data-analtyics`
creares a virtualenv called data-analytics
### 8.1. Multiple virtual envs
`pyenv local data-anlytics formatters`