首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >激活虚拟环境时,pyenv不再正确地设置路径。

激活虚拟环境时,pyenv不再正确地设置路径。
EN

Stack Overflow用户
提问于 2021-05-10 16:05:24
回答 5查看 11.2K关注 0票数 19

我使用pyenv已经将近两年了,我的系统在X11模式下运行RHEL8.3(LinuxKern4.18)和Gnome3.32.2没有问题。我主要使用的是鱼壳,也偶尔也会使用bash,两者都与pyenv一起工作到现在为止。但是,在大约24小时前运行pyenv update之后,使用pyenv activate命令激活我创建的虚拟环境中的一个不再设置使用我在该虚拟环境中安装的内容的路径。

当我启动终端会话时,我看到一条新消息:

代码语言:javascript
运行
复制
WARNING: `pyenv init -` no longer sets PATH.
Run `pyenv init` to see the necessary changes to make to your configuration.

所以我运行了pyenv init,它告诉我:

代码语言:javascript
运行
复制
# 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

代码语言:javascript
运行
复制
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

代码语言:javascript
运行
复制
# 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

代码语言:javascript
运行
复制
# 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 -)"

还有几点意见:

我发现,尽管我有environment.

  • Putting,但当我登录到桌面set -Ux PYENV_ROOT $HOME/.pyenv~/.profile~/.config/fish/config.fish中的set -Ux fish_user_paths $PYENV_ROOT/bin $fish_user_paths并没有什么区别时,它就没有来源/运行。

最后,即使激活了pyenv创建的虚拟环境,我仍然无法访问其中的内容。

我如何解决这个问题?谢谢。

EN

Stack Overflow用户

发布于 2021-06-28 21:41:24

对于Mac和fish,将其添加到~/.config/fish/config.fish

代码语言:javascript
运行
复制
set PYENV_ROOT $HOME/.pyenv
set -x PATH $PYENV_ROOT/shims $PATH
set -x PATH $PYENV_ROOT/bin $PATH

if command -v pyenv 1>/dev/null 2>&1
    pyenv init - | source
end
票数 5
EN
查看全部 5 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/67473902

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档