[英]pyenv-virtualenv python version does not change on env activation
我在使用 pyenv-virtualenv 激活虚拟环境时遇到了一些问题。 当我使用 pyenv 激活一个环境时,它看起来像工作了。 但是 python 版本没有改变。 激活它的唯一方法是手动运行相应文件夹中的激活脚本:
/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) ➜ ~
我将这两行添加到我的.zshrc
:
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
我在 M1 MacBook Pro 上的 macOS 11.6 上使用 zsh 和 Oh My Zsh。
如果您使用的是 Pyenv 2.0+,还要将eval "$(pyenv init --path)"
添加到.zprofile
并确保您的终端运行 Zsh 作为登录名 shell。
(请参阅https://github.com/pyenv/pyenv#readme中 Zsh 在 MacOS 中的安装说明)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.