无法使用pyenv激活virtualenv [英] Failed to activate virtualenv with pyenv
本文介绍了无法使用pyenv激活virtualenv的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我跑步:
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
I am trying to follow this tutorial: 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
:
I recently made my .bash_profile
it contains:
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?
What should I do to properly start virtualenv?
推荐答案
那个
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
应位于 .bashrc
中,而不是 .bash_profile
中.后者仅由 login shell执行,前者由所有交互式shell执行.
should be in .bashrc
, not .bash_profile
. The latter is executed only by login shells, the former by all interactive shells.
这篇关于无法使用pyenv激活virtualenv的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文