Recently, I've been spending more time learning Python as it's the core language used in the framework that we'll be building on. Similar to using docker to containerize apps or vm's to isolate the app env from messing up the local m/c, python provide's various options to isolate the development environment. One such tool is pyenv. It's such an effective tool that makes life much easier, especially when you're working with multiple python projects that may require different dependencies and different versions of one or more python modules.
Here, I've listed out most of the pyenv commands I used to work around different projects in my development env:
- To list versions that match a pattern
$ pyenv install --list | grep " 3\.[678]"
- To install a specific version
$ pyenv install 3.8.2
- To uninstall a specific version
$ pyenv uninstall 3.8.2
- Installation Location
$ ls ~/.pyenv/versions
- To list all available python versions
$ pyenv versions
- To list all pyenv commands
$ pyenv commands
- To set a python version globally
$ pyenv global 3.8.2
- To set a python version locally
$ pyenv local 3.8.2
- To set a python version current shell
$ pyenv shell 3.8.2
- Creating virtual environments
$ pyenv virtualenv 3.8.2 <env_name>
- Activating pyenv env (if necessary)
$ pyenv activate <env_name>
$ pyenv deactivate