简体   繁体   中英

pyenv-virtualenv python version does not change on env activation

I've got some problems with activating virtual environments using pyenv-virtualenv. When I activate an environment with pyenv, it looks like it worked. However the python version has not changed. The only way to activate it is to manually run the activation script in the corresponding folder:

/usr/bin/python
➜  ~ pyenv activate test_env 
pyenv-virtualenv: prompt changing will be removed from future release. configure `export PYENV_VIRTUALENV_DISABLE_PROMPT=1' to simulate the behavior.
(test_env) ➜  ~ which python
/usr/bin/python
(test_env) ➜  ~ source .pyenv/versions/test_env/bin/activate
(test_env) ➜  ~ which python
/Users/tom/.pyenv/versions/3.9.6/envs/test_env/bin/python
(test_env) ➜  ~ 

I added these two lines to my .zshrc :

eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"

I'm using zsh with Oh My Zsh on macOS 11.6 on an M1 MacBook Pro.

If you're using Pyenv 2.0+, also add eval "$(pyenv init --path)" to .zprofile and make sure your Terminal runs Zsh as a login shell.

(See installation instructions for Zsh in MacOS in https://github.com/pyenv/pyenv#readme )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM