Installed pyenv using homebrew and so far i've had no luck getting pyenv to switch python versions. These are the steps I took:
$ brew install pyenv (successful)
$ pyenv install 3.5.2 (successful)
$ python --version
Python 2.7.11
$ pyenv global 3.5.2
$ python --version
Python 2.7.11
$ echo $PATH
/opt/local/bin:/opt/local/sbin:/Users/Eli/.rvm/gems/ruby-2.2.1/bin:/Users/Eli/.rvm/gems/ruby-2.2.1@global/bin:/Users/Eli/.rvm/rubies/ruby-2.2.1/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/go/bin:/Users/Eli/.rvm/bin
I don't see either of the following in your path, which leads me to believe eval "$(pyenv init -)" isn't being run on startup of your shell.
$PYENV_ROOT/shims$PYENV_ROOT/binThat was it! Thank you.
~
Eli Gregory
On Wed, Mar 8, 2017 at 5:50 PM, Connor Ameres notifications@github.com
wrote:
I don't see either of the following in your path, which leads me to
believe eval "$(pyenv init -)" isn't being run on startup of your shell.
- $PYENV_ROOT/shims
- $PYENV_ROOT/bin
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/pyenv/pyenv/issues/849#issuecomment-285229619, or mute
the thread
https://github.com/notifications/unsubscribe-auth/ACDqwqBZl9qYYi6wZfcKA9q5kG7kJbriks5rj1rTgaJpZM4MTNYg
.
Hi @blueyed
Facing this same issue @eligreg please what was the fix, thanks!
@temiadesina
Running the command pyenv init and the do the following fixed the issue for me.
# Load pyenv automatically by appending
# the following to ~/.zshrc:
eval "$(pyenv init -)"
Didn't work for me although pyenv local xxx.xxx works.
eval "$(pyenv init -)" in my ~/.zshrc when I use zsh shell or
status --is-interactive; and source (pyenv init -|psub) in my ~/.config/fish/config.fish when I use fish shell.
for some reason, this is not working for me:
if which pyenv-virtualenv-init > /dev/null
then
eval "$(pyenv virtualenv-init -)"
fi
so I had to remove the which conditions, leaving just the eval line, and start a new login shell and it then worked. I do have pyenv-virtualenv-init installed but somehow the shell was borking. In case others have similar issues.
it may help others to know -
add the eval to the end of the .zshrc file
Based on the README I thought the steps in Basic Github Checkout were only if you didn't do a brew install. Running steps 2 and 3 after installing through brew fixed this problem for me.
For my the problem was that I had a file at $HOME/.python-version with a fixed version.
Removing the file fixed it.
In my case, the issue only happens in my WebStorm's (or other intellij IDE) terminal. ITerm2 is working correct.
Hi all, I'm experiment the same issue.
I've installed via pyenv python 3.8.0, but when I switch (using local or global) nothing changes: the system python is still the one used.
I've added this to my .zshrc, but nothing changed:
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
Don't work even in .zshenv as suggested. Nothing also in .bash_profile.
I'm using macOS Mojave 10.14.6. Terminal is iTerm and shell zsh.
Thanks in advance for any help.
if everything below doesn't work, maybe you can take a try of
which python3
(this seems to be a joke, but it costs me hours to figure out.)
On my system:
$ which python3
/usr/local/bin/python3
And thanks for your tiem, @rony13.
If none of the above works, check whether your path to pyenv in PATH is relative, eg.:
/home/user/scripts/../.pyenv/bin
/home/user/scripts/../.pyenv/shims
In such case, pyenv will appear to be working properly, but the python binary won't actually be looked up in the shims directory. I've encountered this problem with zsh.
I tried again installing using pyenv installer instead of brew and I'm still in the same stiuation!
Just to let know.
Try this: eval "$(pyenv init -)
Example:
$ python -V
Python 2.7.9
mac:~ $ eval "$(pyenv init -)"
mac:~ $ python -V
Python 3.5.0
I solved with help in another issue. _Simply_ creating a new user for Catalina.
It may take time, you need to remove all apps installed with brew and install everything again (without forgotting to backuping you dot files!).
I had this problem as well. Seems like pyenv shell 3.8.1 runs every time I open the terminal. I fixed this by running pyenv shell --unset. Now I just have to find out why pyenv shell 3.8.1 run every time I open the terminal in vs code...
pyenv shell --help
Usage: pyenv shell <version>...
pyenv shell -
pyenv shell --unset
Sets a shell-specific Python version by setting the `PYENV_VERSION`
environment variable in your shell. This version overrides local
application-specific versions and the global version.
<version> should be a string matching a Python version known to pyenv.
The special version string `system' will use your default system Python.
Run `pyenv versions' for a list of available Python versions.
When `-` is passed instead of the version string, the previously set
version will be restored. With `--unset`, the `PYENV_VERSION`
environment variable gets unset, restoring the environment to the
state before the first `pyenv shell` call.
I was having the same issue with fish and I couldn't figure it out for the life of me. I was about ready to destroy my user profile and start from scratch. Somewhere along the way of trying to get pyenv setup initially I somehow set local version in my user directory ~/.python-version which looked very similar to ~/.python/version so I didn't catch it when looking at pyenv versions.
If anyone else is an idiot like me, deleting the .python-version in your root user folder (or any current folder you might be in with a .python-version local config) will obviously fixed it...
it may help others to know -
add the eval to the end of the .zshrc file
just add "eval "$(pyenv init -)"" to .zshrc is working for me. Remove if conditions
I was having the same issue with fish and I couldn't figure it out for the life of me. I was about ready to destroy my user profile and start from scratch. Somewhere along the way of trying to get pyenv setup initially I somehow set local version in my user directory
~/.python-versionwhich looked very similar to~/.python/versionso I didn't catch it when looking atpyenv versions.If anyone else is an idiot like me, deleting the .python-version in your root user folder (or any current folder you might be in with a .python-version local config) will obviously fixed it...
I find the toxic file ~/.python-version is created by pyenv local + system or any other python version name.
I checked this link, and run pyenv local system, trying to just deactivate the virtual env. The correct one is pyenv global system.
If any bash users are struggling with this, add eval "$(pyenv init -)" to your .bashrc (or .bash_profile) instead of the long, complicated line you find in the setup instructions. And thanks to all the people who provided their inputs here!
I find the toxic file
~/.python-versionis created bypyenv local
This is working as intended. If you execute pyenv local 3.8.5 for example while at your HOME directory, you will create that hidden file which overrides global when you are running python from that location. It's supposed to go within a project folder. Yes, deleting it fixed my problem also, so thanks! I just think "toxic" is bit strong. User error is a better descriptor.
Most helpful comment
I don't see either of the following in your path, which leads me to believe
eval "$(pyenv init -)"isn't being run on startup of your shell.$PYENV_ROOT/shims$PYENV_ROOT/bin