gpt4 book ai didi

python - 无法使用 pyenv 激活 virtualenv

转载 作者:太空狗 更新时间:2023-10-29 17:12:10 25 4
gpt4 key购买 nike

我跑:

pyenv activate new_app

然后我得到:

Failed to activate virtualenv.

Perhaps pyenv-virtualenv has not been loaded into your shell properly.
Please restart current shell and try again.

我正在尝试按照本教程进行操作:https://tutorials.technology/tutorials/59-Start-a-flask-project-from-zero-building-api-rest.html

其他信息:

bash-3.2$ python --version
Python 3.6.0

bash-3.2$ pyenv version
3.6.0 (set by /Users/me/Projects/flask_api/.python-version)

bash-3.2$ pwd
/Users/me/Projects/flask_api

bash-3.2$ pyenv versions
system
3.5.1
3.5.1/envs/my_env_3_5_1
* 3.6.0 (set by /Users/me/Projects/flask_api/.python-version)
3.6.0/envs/new_app
flask_app
my_env_3_5_1
new_app

bash-3.2$ virtualenv --version
15.1.0

bash-3.2$ pyenv virtualenvs
3.5.1/envs/my_env_3_5_1 (created from /Users/me/.pyenv/versions/3.5.1)
3.6.0/envs/new_app (created from /Users/me/.pyenv/versions/3.6.0)
flask_app (created from /System/Library/Frameworks/Python.framework/Versions/2.7)
my_env_3_5_1 (created from /Users/me/.pyenv/versions/3.5.1)
new_app (created from /Users/me/.pyenv/versions/3.6.0)

我最近制作了我的 .bash_profile 它包含:

bash-3.2$ cat ~/.bash_profile 
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
exec "$SHELL"
if which pyenv-virtualenv-init > /dev/null; then eval "$(pyenv virtualenv-init -)"; fi

我应该怎么做才能正确启动 virtualenv?

最佳答案

那个

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

应该在 .bashrc 中,而不是 .bash_profile。后者仅由 login shell 执行,前者由所有交互式 shell 执行。

关于python - 无法使用 pyenv 激活 virtualenv,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45577194/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com