or how I learned to stop worrying and get things done with python
focusing on "weapon-system" macOS cross-platform, including windows to some extent https://github.com/pyenv/pyenv
problem: dependency hell python2 v python3 pip / pip3
goal: install in user space install multiple versions choose what version you want to use change between versions easily
why not use system python? think of as belonging to the system which python also an old (now depricated?) version python -V requires sudo pip install (global), issue with multiple users ** some OS actually use packaged python, ex. yum. let's not break it package manager? typically install packages in global system space (not user) things just get mucked up fast, soil your environment
solution: pyenv (gh image)
installation overview deps: $ brew install openssl readline sqlite3 xz zlib # mojave+ $ sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target / $ curl https://pyenv.run | bash
WARNING: seems you still have not added 'pyenv' to the load path.
# Load pyenv automatically by adding
# the following to ~/.bashrc:
export PATH="$HOME/.pyenv/bin:$PATH"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
(restart terminal)
where it's installed: $ ls ~/.pyenv/versions/ $ pyenv uninstall 2.7.15 OR $ rm -rf ~/.pyenv/versions/2.7.15
installation lab
using pyenv overview
pyenv usage lab getting info $ pyenv # list available cli options $ pyenv install --list (grep!) # list packages / versions available $ pyenv install -v 3.7.2 # install $ pyenv versions # list installed versions $ pyenv version # list active version $ pyenv global 2.7.15 # set new global version
scope global # use a particular Python version "by default" local # used to set an application-specific Python version $ pyenv local x.x.x creates a .python-version file in your current directory shell # set a shell-specific Python version $ pyenv shell x.x.x
virtual environments create an isolated environment for Python projects. each project can have its own dependencies, regardless of dependencies this may fit your existing workflow...
process overview: $ pyenv virtualenv <python_version> <environment_name> $ pyenv virtualenv 3.6.8 myproject
$ pyenv local myproject # activate the new env