Homebrew:
$ brew update
$ brew install pyenv
Once pyenv
is installed, follow step 3 here.
To isolate projects from one another, I use poetry instead of managing my own virtualenv. Since poetry
can detect whether I’m currently in an activated virtualenv
, it will use that existing one or create a new one.
To install poetry
:
$ curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python -
When I use poetry
, I either initialize a new project with poetry new
or create a new project by hand with poetry init
:
$ mkdir new-proj && cd new-proj
$ poetry init
All of my .virtualenv
s also exist outside of my project folders and in my home directory ($HOME/.virtualenvs
).
$ poetry config virtualenvs.path $HOME/.virtualenvs
The default .virtualenv
path of poetry
is {cache-dir}/virtualenvs
which can be a bit harder to find depending on your OS. If you’re like me and you use PyCharm, finding that virtualenv
so you can configure your Project Interpreter
can be a pain.
I’ve found that this setup requires the least effort and works just as well when I need to work with scientific packages.