Install pyenv
, but don't use shims and pyenv init
to prevent pyenv
from
intercepting common executables with its shim. e.g. if you have tox
installed
as a pex
standalone executable, but also in a pyenv
-managed virtual
environment, pyenv
will intercept a call to tox
.
Use the pyenv
installer with curl https://pyenv.run | bash
.
Remove any eval
of pyenv init
or pyenv virtualenv-init
that the installer
added to ~/.bash_profile
. Keep or add export PATH="$HOME/.pyenv/bin:$PATH"
in ~/.bash_profile
.
pyenv
will only be used to manage installation of different
versions of Python. e.g. install Python 3.8.8 with pyenv install 3.8.8
. Then
add this version's location to your path to make it the default Python.
Restart your shell to update PATH
.
Now install poetry
.
curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python3
And add poetry
bash completions (assuming homebrew on a Mac here):
poetry completions bash > $(brew --prefix)/etc/bash_completion.d/poetry.bash-completion
echo "source $(brew --prefix)/etc/bash_completion.d/poetry.bash-completion" >> ~/.bash_profile
In the end, the cumulative changes to ~/.bash_profile
should look like this:
export PATH="$HOME/.pyenv/bin:$PATH"
export PATH="$HOME/.pyenv/versions/3.8.8/bin:$PATH"
export PATH="$HOME/.poetry/bin:$PATH"
source /usr/local/etc/bash_completion.d/poetry.bash-completion