gpt4 book ai didi

python - pyenv 在激活虚拟环境时不再正确设置路径

转载 作者:行者123 更新时间:2023-12-04 04:24:47 27 4
gpt4 key购买 nike

我已经使用 pyenv 将近两年了,在 X11 模式下运行 RHEL 8.3(Linux 内核 4.18)和 Gnome 3.32.2 的系统上没有任何问题。我主要使用 fish shell ,但偶尔也使用 bash,直到现在都可以正常使用 pyenv。然而,在运行 pyenv update 之后大约 24 小时前,使用 pyenv activate激活我创建的虚拟环境之一的命令不再设置使用我在该虚拟环境中安装的内容的路径。
当我开始一个终端 session 时,我看到一条新消息说:

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
我的 ~/.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 ,当我登录到我的桌面环境时,它永远不会被获取/运行。
  • set -Ux PYENV_ROOT $HOME/.pyenvset -Ux fish_user_paths $PYENV_ROOT/bin $fish_user_paths~/.profile~/.config/fish/config.fish没有什么区别。

  • 最后,即使激活了 pyenv 创建的虚拟环境,我仍然无法访问其中的内容。
    我该如何解决这个问题?谢谢你。

    最佳答案

    操作系统:ubuntu 18.04我更新了pyenv经过

    pyenv update 
    它开始显示这个警告
    WARNING: `pyenv init -` no longer sets PATH.
    Run `pyenv init` to see the necessary changes to make to your configuration.
    pyenv不再正确设置路径
    使固定

  • 我的 ~/.bashrc 中有这些行.所以, 删除/评论如果您在 ~/.bashrc 中有这些行
    export PATH="/home/yogi/.pyenv/bin:$PATH"
    eval "$(pyenv init -)"
    eval "$(pyenv virtualenv-init -)"

  • ~/.profile 中添加这些行 之前 采购 ~/.bashrc
    export PYENV_ROOT="$HOME/.pyenv"
    export PATH="$PYENV_ROOT/bin:$PATH"
    eval "$(pyenv init --path)"

  • 源配置文件
    source ~/.profile

    关于python - pyenv 在激活虚拟环境时不再正确设置路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67473902/

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