I am try to upgrade my Python version on my macOS Catalina 10.15.1 by install PYENV and PYPIP, and set global and local to version 3.8.0. but still when I try to python version it shows the python version which built into the MacOS operating system. which part is missing?
$ pyenv -v
pyenv 1.2.14
$ pypip -v
zsh: command not found: pypip
$ pyenv versions
system
* 3.8.0 (set by /Users/aj/.python-version)
$ pyenv global
3.8.0
$ pyenv local
3.8.0
$ python -V
Python 2.7.16
For me OSX I had to put
eval "$(pyenv init --path)"
inside my ~/.bashrc | ~/.zshrc
note that without the --path it didn't work
If the output of
type -a python
is /usr/bin/python
, and if there is no second line displayed, then pyenv is only setup partially.
You should have seem as first line something like
/home/username/.pyenv/shims/python
That means your pyenv is not setup properly. It is only set up partially. What's missing is the pyenv shims which redirect to the correct version of python.
Probably your search path contains:
/home/username/.pyenv/bin
, but it is missing /home/username/.pyenv/shims
(Following comments updated 2021-01-06):
Normally you should have three lines in your ~/.bashrc
The first two (or something equivalent), that you seem to have are:
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bash_profile
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bash_profile
On the other hand what you seem to be missing is a line, that looks like:
echo 'eval "$(pyenv init -)"' >> ~/.bash_profile
or a more elaborate but in most cases identical line:
echo -e 'if command -v pyenv 1>/dev/null 2>&1; then\n eval "$(pyenv init -)"\nfi' >> ~/.bash_profile
Try to add one of these missing lines to your .bashrc and see whether pyenv is working better.
You could also add ~/.pyenv/shims/python
manually to your searchpath, but normally this should have been done by the eval "$(pyenv init -)"
command
if ~/.pyenv/shims
is already in your search path, then check with
ls ~/.pyenv/shims
whether the directory exists and contains an executable named python.
Normally this should have been added latest after having done a pyenv install 3.8.0
Addendum 2022-01-15:
Please note that the way pyenv is initialized changed. If you had an older pyenv version and you updated the cloned repository you have probably something like
eval "$(pyenv init -)"
in your ~/.bash_profile
This has to be changed to something lile
eval "$(pyenv init -)"
eval "$(pyenv init --path)"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With