Tags: #python3 #pip #deps #dependencies #venv #virtualenvironment #env #tfswitch #tf #terraform
† for the project I was working on they did suggest I could also use the
-e, --editable
flag to install multiple deps required (this basically installs the deps locally and symlinks up the main imported package such that any changes made to the package code would be immediately reflected wherever you were importing that code).
To get different Python interpreters install python-build
and pyenv
(installing the latter should install both anyway).
e.g. brew install pyenv
Then you can check Python versions available with python-build --definitions
and install them using (for example) pyenv install 3.8-dev
.
Make sure you add eval "$(pyenv init -)"
to your bashrc so that when you go to a directory with .python-version
file the shell will immediately activate the specified Python version (as long as it’s installed that is).
Now you can use pyenv local 3.8-dev
to enable a Python version (which itself will create a .python-version
file in that directory).
From there you can install dependencies using python -m pip install ...
or you can create a virtual environment to install them like so mkdir ProjectA && pyenv virtualenv testing-a
(which requires brew install pyenv-virtualenv
) and then activate it using pyenv activate testing-a
.