我已经使用 pyenv 近两年了,在 X11 模式下运行 RHEL 8.3(Linux 内核 4.18)和 Gnome 3.32.2 的系统上没有出现任何问题。我主要使用 Fish shell,但偶尔也会使用 bash,到目前为止,两者都可以很好地与 pyenv 配合使用。然而,运行后pyenv update
大约 24 小时前,使用pyenv activate
用于激活我创建的虚拟环境之一的命令不再设置使用我在该虚拟环境中安装的内容的路径。
当我启动终端会话时,我看到一条新消息:
WARNING: `pyenv init -` no longer sets PATH.
Run `pyenv init` to see the necessary changes to make to your configuration.
所以我跑了pyenv init
这告诉我:
# Add pyenv executable to PATH by adding
# the following to ~/.profile:
set -Ux PYENV_ROOT $HOME/.pyenv
set -Ux fish_user_paths $PYENV_ROOT/bin $fish_user_paths
# Load pyenv automatically by appending
# the following to ~/.config/fish/config.fish:
pyenv init - | source
# and the following to ~/.profile:
pyenv init --path | source
# If your ~/.profile sources ~/.config/fish/config.fish,
# the lines should be inserted before the part
# that does that.
# Make sure to restart your entire logon session
# for changes to ~/.profile to take effect.
我很确定我已经拥有以上所有内容。这是我的~/.profile
:
set -Ux PYENV_ROOT $HOME/.pyenv
set -Ux fish_user_paths $PYENV_ROOT/bin $fish_user_paths
pyenv init --path | source
这是我的~/.config/fish/config.fish
:
# Set default editor
set -gx EDITOR nano
# Set Junest path
set PATH /home/[username]/.local/share/junest/bin $PATH
# Set pyenv root directory
set PYENV_ROOT $HOME/.pyenv
# Add pyenv and local bin to $PATH
set PATH $PYENV_ROOT/bin /home/[username]/.local/bin $PATH
# Add pyenv init to shell to enable shims and autocompletion
# Note the command `pyenv init` will tell you to add this line for fish
status --is-interactive; and source (pyenv init -|psub)
pyenv init - | source
My ~/.bashrc
:
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
# User specific environment
PATH="$HOME/.local/bin:$HOME/bin:$PATH"
export PATH
# Uncomment the following line if you don't like systemctl's auto-paging featur$
# export SYSTEMD_PAGER=
# User specific aliases and functions
# Load pyenv
export PATH="$HOME/.pyenv/bin:$PATH"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
还有一些观察结果:
- 我发现即使我有
~/.profile
,当我登录桌面环境时,它永远不会被获取/运行。
- Putting
set -Ux PYENV_ROOT $HOME/.pyenv
and set -Ux fish_user_paths $PYENV_ROOT/bin $fish_user_paths
in ~/.profile
or ~/.config/fish/config.fish
没有什么区别。
最后,即使在激活 pyenv 创建的虚拟环境后,我仍然无法访问其中的内容。
我该如何解决这个问题?谢谢。