'pyenv does not use correct python version
using pyenv 2.0.3
when i'm in a folder with a python-version file, the python keeps using the system version which is 2.7.6. (not sure why it is 2.7.6 since i install 3.9.7 via brew).
$ python -V
Python 2.7.16
looking via pyenv gives
$ pyenv which python
/Users/jaco/.pyenv/versions/trading/bin/python
Activating it already says it is activated.
i have
# pyenv
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
in my zshrc
also don't seem to have the bin folder of pyenv? is this new on the v2?
$ l /Users/jaco/.pyenv/bin
ls: /Users/jaco/.pyenv/bin: No such file or directory
Also setting pyenv global 3.9.1
does not work, it keeps 2.7
Solution 1:[1]
The answer is to put the shims on the path
# pyenv
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/shims:$PATH"
if which pyenv-virtualenv-init > /dev/null; then eval "$(pyenv virtualenv-init -)"; fi
#if which pyenv > /dev/null; then eval "$(pyenv init -)"; fi
Solution 2:[2]
Assuming you're running MacOS and have installed pyenv
via Homebrew, you'll need to do the following:
# Adjust the session-wide environment for your account.
echo 'eval "$(pyenv init --path)"' >> ~/.zprofile
# Enable autocompletion and all subcommands
echo 'eval "$(pyenv init -)"' >> ~/.zshrc
From pyenv installation docs:
MacOS note: If you installed Pyenv with Homebrew, you don't need to add the PYENV_ROOT= and PATH= lines. You also don't need to add commands into ~/.profile if your shell doesn't use it.
Solution 3:[3]
I was on my ~
folder and trying to run pyenv global 3.10.4
BUT python -V
was only running 3.8.3
tried everything and was in despair.
The problem was that on my ~
there was a .python-version
file pointing to 3.8.3
.
Solution: check and remove .python-version
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Tjorriemorrie |
Solution 2 | j4ckofalltrades |
Solution 3 | Jorge Mendes |