pyenv global command doesn't set the correct python version
Asked Answered
A

1

5

So I activated this virutal environment:

pyenv install 3.7.4
pyenv virtualenv 3.7.4 apps3
pyenv local apps3
pyenv activate apps3

and also set this:

pyenv global 3.7.4

I already have these in my .zshrc profile as suggested here:

$ export PATH="$HOME/.pyenv/bin:$PATH"
$ eval "$(pyenv init -)"
$ eval "$(pyenv virtualenv-init -)"

However, even then, when I activate the apps3and check for python --version, I keep getting Python 2.7.16, which is the default Python of my system. How can I fix this?

Anemoscope answered 2/2, 2022 at 10:29 Comment(0)
D
10

Apparently Pyenv did change the behavior of manipulating the path.

Change the line in your .zshrc from

eval "$(pyenv init -)"

to

eval "$(pyenv init --path)"

Then resource your .zshrc and retry.

My sources for this are: https://github.com/pyenv/pyenv-virtualenv/issues/401#issuecomment-903635119 and https://github.com/pyenv/pyenv/issues/1649#issuecomment-694388530

(This is my first post on stackoverflow. I apologize if this is not up to the standards and am more than willing to learn if you give me pointers. Thanks)

Dandruff answered 3/2, 2022 at 21:19 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.