I have a new MacBook with fresh installs of everything which I upgraded to macOS Catalina. I installed homebrew and then pyenv, and installed Python 3.8.0 using pyenv. All these things seemed to work properly.
However, neither pyenv local
nor pyenv global
seem to take effect. Here are all the details of what I'm seeing:
thewizard@Special-MacBook-Pro ~ % pyenv versions
system
* 3.8.0 (set by /Usersthewizard/.python-version)
thewizard@Special-MacBook-Pro ~ % python --version
Python 2.7.16
thewizard@Special-MacBook-Pro ~ % pyenv global 3.8.0
thewizard@Special-MacBook-Pro ~ % python --version
Python 2.7.16
thewizard@Special-MacBook-Pro ~ % pyenv local 3.8.0
thewizard@Special-MacBook-Pro ~ % python --version
Python 2.7.16
thewizard@Special-MacBook-Pro ~ % echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/thewizard/.pyenv/bin
thewizard@Special-MacBook-Pro ~ % cat ~/.zshenv
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
if command -v pyenv 1>/dev/null 2>&1; then
eval "$(pyenv init -)"
fi
BTW there is no /bin
in my .pyenv, I only added those commands per some other instructions but I'm planning to remove it because I think it is wrong:
thewizard@Special-MacBook-Pro ~ % ls -al ~/.pyenv
total 8
drwxr-xr-x 5 thewizard staff 160 Nov 2 15:03 .
drwxr-xr-x+ 22 thewizard staff 704 Nov 2 15:36 ..
drwxr-xr-x 22 thewizard staff 704 Nov 2 15:03 shims
-rw-r--r-- 1 thewizard staff 6 Nov 2 15:36 version
drwxr-xr-x 3 thewizard staff 96 Nov 2 15:01 versions
It's worth noting that Catalina moved to zsh from bash, not sure if that's relevant here.
$PATH
, it seems the system directories/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
all have precedence over your pyenv directory. If your system has Python 2.7 in/usr/local/bin
, runningpython
will use Python 2.7 in that case. Can you set the path manually withexport PATH="/Users/thewizard/.pyenv/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
and re-try? – Polyzoarium.zshenv
, which overwrites your path. Does your.zshrc
overwrite the$PATH
? – Polyzoarium~/.pyenv/versions/3.8.0/
As for.zshrc
that file doesn't exist. I don't have otherzsh
files in my home directory, and in fact.zshenv
is a file I made myself. – Mahdi.zshrc
file. Incidentally one of the commands (withvirtualenv-init
in it) gives an error to me, but things seem to work regardless. Thanks for the tip! – Mahdi