Instructions for setting up Python for both using Python-based applications and developing such applications yourself. Instructions are for mac OS only.
These are mostly notes for myself.
This will install pyenv and set the global interpreter (not the system interpreter) to a reasonably recent Python version.
$ curl https://pyenv.run | bash
$ exec $SHELL
Then fetch a list of all available Python versions:
$ pyenv install --list
Pick one (at least 3.6.0) and run:
$ pyenv install <your chosen version>
$ pyenv global <your chosen version>
Verify that the global Python is now the version you chose:
$ python --version
Update pip to the newest version:
$ python -m pip update pip
Note that you can even use pyenv to install Conda!
$ python3 -m pip install --user pipx
$ python3 -m pipx ensurepath
To install a program and make it available globally:
$ pipx install <programs you use>
This will install each program in its own virtual env so they're completely separate and won't ruin your system's Python distribution.
Create the file $HOME/.pip/pip.conf
and put this in it:
[global]
require-virtualenv = true
This will not disallow pip to install packages outside of a virtual environment. To install packages globally, use pipx.
Create a new environment with a specific Python version:
$ pyenv virtualenv <python version> <env name>
You can now activate whenever you wish:
$ pyenv activate <env name>
$ # do you work
$ pyenv deactivate
To get rid of an environmet:
$ pyenv uninstall <env name>
The awesome Nox library will automatically pick up different Python versions installed with pyenv.