python3 command not found after installing python with pyenv

phani picture phani · May 18, 2018 · Viewed 9.8k times · Source

I installed a specific version of python with pyenv. When typed pyenv version in terminal, i see 3.5.0 (set by /Users/lcherukuri/.python-version). But when I typed python3, I got python3 command not found. How to fix this? pip3 is Also not found

Answer

jmkmay picture jmkmay · May 18, 2018

pyenv is just a Python version manager. It may be able to see a Python 3.X installed even if python3 isn't 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.