我在使用 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。