pip – python3 command not found after installing python with pyenv
pip – python3 command not found after installing python with pyenv
If you installed both python 2.x and python 3.x using pyenv, run the following to enable both versions to be found globally (python, python2 and python3 aliases).
Add the specific versions you are using:
pyenv global 3.8.3 2.7.18
pyenv
is just a Python version manager. It may be able to see a Python 3.X installed even if python3
isnt installed in your $PATH.
You need to add python3
to your $PATH. You can see how to do that here.
By default, MacOS uses python3
to differentiate between the native pre-installed python
(which is Python 2.7) and any post-installed Python 3.X distributions. The same goes for pip
and pip3
.
From the pyenv
documentation on managing versions:
Locating the Python Installation
Once pyenv has determined which
version of Python your application has specified, it passes the
command along to the corresponding Python installation.Each Python version is installed into its own directory under $(pyenv
root)/versions.For example, you might have these versions installed:
$(pyenv root)/versions/2.7.8/
$(pyenv root)/versions/3.4.2/
$(pyenvroot)/versions/pypy-2.4.0/
As far as pyenv is concerned, version names
are simply the directories in $(pyenv root)/versions.
pip – python3 command not found after installing python with pyenv
pyenv
manages shim executables for commands like python3
and pip3
. If pyenvs shims arent available in your shell, it usually means one of two things:
- pyenv isnt fully installed
or
- pyenv shell features arent active
As your pyenv command is working but the shims arent, it most likely means the shell features arent activated. As of writing, the correct way is to ensure the init command output is evaluated. On macOS, you can add the following to your ~/.bash_profile:
eval $(pyenv init -)
Older installation instructions might not include that step or just have you add pyenvs bin directory to the PATH, which is not enough. If you used pyenv-installer, this step is hinted at in a warning at the end of the installation process.