我在使用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专业版的macOS 11.6上使用zsh和哦我的Zsh。
发布于 2021-10-07 08:18:52
如果您使用的是Pyenv,还要将eval "$(pyenv init --path)"添加到.zprofile中,并确保您的终端将Zsh作为登录2.0+运行。
(请参考https://github.com/pyenv/pyenv#readme中MacOS中Zsh的安装说明)
https://stackoverflow.com/questions/69388462
复制相似问题