Reputation: 730
I have MacOS Catalina and I went ahead and did a brew install
for the latest version of python
3.8.5. Then I discovered pyenv
and installed that as well. I followed the steps on https://github.com/pyenv/pyenv#basic-github-checkout from number 3 but still can't see any python versions in pyenv
.
I have both .zprofile and .zshrc files and am wondering if that's causing issues. Here's my echo $PATH
-
/Users/pq0252/.pyenv/shims/shims:/Users/pq0252/.pyenv/shims/shims:/Users/pq0252/.pyenv/shims:/Library/Frameworks/Python.framework/Versions/3.8/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
Here's the pyenv version output:
pyenv versions
* system (set by /Users/pq0252/.pyenv/shims/version)
Here's the .zprofile
contents -
#Setting PATH for Python 3.8.
#The original version is saved in .zprofile.pysave.
PATH="/Library/Frameworks/Python.framework/Versions/3.8/bin:${PATH}"
export PATH
Here's the .zshrc
contents (this seems to be repeating the if
condition, even though I only added it once which I am thinking has something to do with the step 3 on pyenv
github where we are appending to it?).
export PYENV_ROOT="$HOME/.pyenv/shims"
export PATH="$PYENV_ROOT:$PATH"
export PIPENV_PYTHON="$PYENV_ROOT/python"
echo -e 'if command -v pyenv 1>/dev/null 2>&1; then\n eval "$(pyenv init -)"\n$
if command -v pyenv 1>/dev/null 2>&1; then
eval "$(pyenv init -)"
fi
if command -v pyenv 1>/dev/null 2>&1; then
eval "$(pyenv init -)"
fi
Should I remove entries in .zshrc
and instead add everything to .zprofile
or is there something else I'm missing? python3 --version
does show 3.8.5.
Upvotes: 5
Views: 5935
Reputation: 1570
Here's what I see when I run pyenv versions
➜ ~ pyenv versions
* system (set by /Users/gwanghyeongim/.pyenv/version)
3.7.6
3.7.7
And this is what I have in my .zshrc
file.
# pyenv config
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
Your PYENV_ROOT
and PATH
in .zshrc
looks odd. According to the installation guide, they should looke something like above. Make them like above.
It seems instead of running echo -e 'if command -v pyenv 1>/dev/null 2>&1; then\n eval "$(pyenv init -)"\nfi' >> ~/.zshrc
in terminal, you put it in .zshrc
directly. Remove the code block starting echo -e
and run the code in the terminal instead. Then your .zshrc
will look like something above.
Now try running pyenv install version_to_install
, where version_to_install is python you want to install with pyenv. For exmaple
pyenv install 3.7.7
Then it will install the specific version. After it's installed, run pyenv versions
again and see if you see the installed python version too in the list.
Upvotes: 3