Bash 无法通过shellscript激活virtualenv
我正试图通过这样一个非常简单的bash脚本来激活我的pyenv virtualenv环境Bash 无法通过shellscript激活virtualenv,bash,shell,virtualenv,fish,pyenv,Bash,Shell,Virtualenv,Fish,Pyenv,我正试图通过这样一个非常简单的bash脚本来激活我的pyenv virtualenv环境 set -e pyenv activate myenv 但我无法激活我的环境,出现以下错误: Failed to activate virtualenv. Perhaps pyenv-virtualenv has not been loaded into your shell properly. Please restart current shell and try again. 我可以在命令行中激
set -e
pyenv activate myenv
但我无法激活我的环境,出现以下错误:
Failed to activate virtualenv.
Perhaps pyenv-virtualenv has not been loaded into your shell properly.
Please restart current shell and try again.
我可以在命令行中激活它,所以我认为这是由于我的shell环境
我使用的是fish shell
,但它是在bash shell
中读取的$PATH
设置之后启动的。
我给你看我的设置
.bash\u配置文件
:
export LANG="ja_JP.UTF-8"
export XDG_CONFIG_HOME="$HOME/.config"
export PATH="/sbin"
export PATH="/usr/sbin:$PATH"
export PATH="/bin:$PATH"
export PATH="/usr/bin:$PATH"
export PATH="/usr/local/bin:$PATH"
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
exec fish
$ echo -e 'if command -v pyenv 1>/dev/null 2>&1; then\n eval "$(pyenv init -)"\nfi' >> ~/.bash_profile
和我的config.fish
:
status --is-interactive; and source (pyenv init -|psub)
status --is-interactive; and source (pyenv virtualenv-init -|psub)
怎么了
我正在使用:
:OS X 10.13.5OS
:v2.7.1fish
:v1.2.5pyenv
:v1.1.3pyenv-virtualenv
~/.bash\u配置文件中:
export LANG="ja_JP.UTF-8"
export XDG_CONFIG_HOME="$HOME/.config"
export PATH="/sbin"
export PATH="/usr/sbin:$PATH"
export PATH="/bin:$PATH"
export PATH="/usr/bin:$PATH"
export PATH="/usr/local/bin:$PATH"
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
exec fish
$ echo -e 'if command -v pyenv 1>/dev/null 2>&1; then\n eval "$(pyenv init -)"\nfi' >> ~/.bash_profile
运行该命令后,我怀疑您的脚本将按预期运行。如果没有,您可以尝试将相同的PyEnv初始化代码段(您刚刚添加到~/.bash_配置文件)添加到bash脚本的顶部。脚本在bash下工作吗?不,在bash下也不工作。