You can use pyenv to work with different versions of python.
To install:
$ brew install pyenvPyenv works with shims. To use them, we need to add this to our shell config:
eval "$(pyenv init -)"Install a version of Python:
$ pyenv install 3.6.0Use a pyenv version globally:
$ pyenv global 3.6.0Use a pyenv version locally:
$ pyenv local 3.6.0This will add a .python-version file to the local directory. When you enter this directory, pyenv will recognize the version of Python you want to use. If this version is not installed, pyenv will let you know you need to install it.
pyenv-virtualenv will allow you to set the version of Python you want to use for a project, and have a contained set of packages (like having a separate gemset in the Ruby world).
Install:
$ brew install pyenv-virtualenvCreate a new environment:
$ pyenv virtualenv 3.6.0 my-project-3.6.0List virtual envs:
$ pyenv vitualenvsRemove a virtual env:
$ pyenv uninstall my-project-3.6.0Use a virtual env for the current project:
$ pyenv local my-project-3.6.0Sometimes you want to know where the location of the installed python you are using is:
$ pyenv which pythonYou can use the pip package manager to install a package:
$ python -m pip install pylintAfter installing a pip package, you can create a requirements file that other can use to load the same packages:
$ python -m pip freeze > requirements.txtThen someone else can load the requirements file:
$ python -m pip install -r requirements.txt