当前位置: 首页 > 知识库问答 >
问题:

Pyenv没有安装其他python

施锋
2023-03-14

我使用pyenv来管理python安装和虚拟环境。我在Mac(Catalina)上安装了几个python。

    < li >系统python(usr/bin中的python 2.7) < Li > usr/bin中的python 3.9(来自python.org/downloads中的默认安装程序) < Li > python 3.9 in/opt/anaconda 3/bin/python 3(来自https://www . anaconda . com/products/individual)

对于一个项目,我需要python 3.6。我知道conda提供了使用特定python版本创建虚拟环境的可能性,但我想尝试使用pyenv来管理不同的python安装。

我遵循了安装指南,并遵循了基本的git检验步骤(针对zsh)。

安装后,我可以找到。pyenv在我的主目录中,一切似乎都很好。我使用pyenv成功安装了python 3.6。当我运行pyenv版本以列出我的所有python安装(并切换到我的conda安装作为测试)时,输出中没有包含我的任何原始python设置(请参阅上面的列表)。输出:

▶ pyenv versions
* system (set by /Users/DVerb5/.pyenv/version)
  3.6.12

我怎样才能让pyenv也找到我的其他蟒蛇安装?我尝试做一些研究,这似乎是可能的。我看了下面的两页,看起来很有希望,但无法弄清楚。

  • 使用 pyenv 安装蟒蛇,无法配置虚拟环境
  • https://wilsonmar.github.io/pyenv/

如前所述,我使用zsh,这是我的.zshrc的内容

# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH

# Path to your oh-my-zsh installation.
export ZSH="/Users/DVerb5/.oh-my-zsh"

# Set name of the theme to load --- if set to "random", it will
# load a random theme each time oh-my-zsh is loaded, in which case,
# to know which specific one was loaded, run: echo $RANDOM_THEME
# See https://github.com/ohmyzsh/ohmyzsh/wiki/Themes
ZSH_THEME="avit"

# Set list of themes to pick from when loading at random
# Setting this variable when ZSH_THEME=random will cause zsh to load
# a theme from this variable instead of looking in $ZSH/themes/
# If set to an empty array, this variable will have no effect.
# ZSH_THEME_RANDOM_CANDIDATES=( "robbyrussell" "agnoster" )

# Uncomment the following line to use case-sensitive completion.
# CASE_SENSITIVE="true"

# Uncomment the following line to use hyphen-insensitive completion.
# Case-sensitive completion must be off. _ and - will be interchangeable.
# HYPHEN_INSENSITIVE="true"

# Uncomment the following line to disable bi-weekly auto-update checks.
# DISABLE_AUTO_UPDATE="true"

# Uncomment the following line to automatically update without prompting.
# DISABLE_UPDATE_PROMPT="true"

# Uncomment the following line to change how often to auto-update (in days).
# export UPDATE_ZSH_DAYS=13

# Uncomment the following line if pasting URLs and another text is messed up.
# DISABLE_MAGIC_FUNCTIONS="true"

# Uncomment the following line to disable colors in ls.
# DISABLE_LS_COLORS="true"

# Uncomment the following line to disable the auto-setting terminal title.
# DISABLE_AUTO_TITLE="true"

# Uncomment the following line to enable command auto-correction.
# ENABLE_CORRECTION="true"

# Uncomment the following line to display red dots whilst waiting for completion.
# COMPLETION_WAITING_DOTS="true"

# Uncomment the following line if you want to disable marking untracked files
# under VCS as dirty. This makes repository status check for large repositories
# much, much faster.
# DISABLE_UNTRACKED_FILES_DIRTY="true"

# Uncomment the following line if you want to change the command execution time
# stamp shown in the history command output.
# You can set one of the optional three formats:
# "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd"
# or set a custom format using the strftime function format specifications,
# see 'man strftime' for details.
# HIST_STAMPS="mm/dd/yyyy"

# Would you like to use another custom folder than $ZSH/custom?
# ZSH_CUSTOM=/path/to/new-custom-folder

# Which plugins would you like to load?
# Standard plugins can be found in $ZSH/plugins/
# Custom plugins may be added to $ZSH_CUSTOM/plugins/
# Example format: plugins=(rails git textmate ruby lighthouse)
# Add wisely, as too many plugins slow down shell startup.
plugins=(
    git
    zsh-syntax-highlighting)

ZSH_DISABLE_COMPFIX=true

source $ZSH/oh-my-zsh.sh

# User configuration

# export MANPATH="/usr/local/man:$MANPATH"

# You may need to manually set your language environment
export LANG=en_US.UTF-8

# Preferred editor for local and remote sessions
# if [[ -n $SSH_CONNECTION ]]; then
#   export EDITOR='vim'
# else
#   export EDITOR='mvim'
# fi

# Compilation flags
# export ARCHFLAGS="-arch x86_64"

# Set personal aliases, overriding those provided by oh-my-zsh libs,
# plugins, and themes. Aliases can be placed here, though oh-my-zsh
# users are encouraged to define aliases within the ZSH_CUSTOM folder.
# For a full list of active aliases, run `alias`.
#
# Example aliases
# alias zshconfig="mate ~/.zshrc"
# alias ohmyzsh="mate ~/.oh-my-zsh"

# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
##__conda_setup="$('/opt/anaconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
##if [ $? -eq 0 ]; then
##    eval "$__conda_setup"
##else
##    if [ -f "/opt/anaconda3/etc/profile.d/conda.sh" ]; then
##        . "/opt/anaconda3/etc/profile.d/conda.sh"
##    else
##        export PATH="/opt/anaconda3/bin:$PATH"
##    fi
##fi
##unset __conda_setup
# <<< conda initialize <<<


alias code="/Applications/Visual\ Studio\ Code.app/Contents/Resources/app/bin/code"

export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
if command -v pyenv 1>/dev/null 2>&1; then
  eval "$(pyenv init -)"
fi

这就是我的路径

echo $PATH
/Users/DVerb5/.pyenv/bin:/Users/DVerb5/.pyenv/shims:/Users/DVerb5/.pyenv/bin:/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/anaconda3/bin```

此外我还注意到哪个pyenv不起作用。它返回以下内容。(我不知道是否相关)

▶ which pyenv
pyenv () {
    local command
    command="${1:-}"
    if [ "$#" -gt 0 ]
    then
        shift
    fi
    case "$command" in
        (rehash | shell) eval "$(pyenv "sh-$command" "$@")" ;;
        (*) command pyenv "$command" "$@" ;;
    esac
} 

共有1个答案

云承弼
2023-03-14

如果您通过pyenv本身安装它,它就会工作。例如,如果运行pyenv安装3.7.4,那么将得到由pyenv管理的3.7.4。我不知道有什么方法可以让pyenv找到以前安装的版本,但添加新版本确实很容易。

 类似资料:
  • 本文向大家介绍Linux下安装pyenv的方法,包括了Linux下安装pyenv的方法的使用技巧和注意事项,需要的朋友参考一下 前置条件 需安装git 安装步骤 1. 从远程仓库中克隆 pyenv 使用下面的命令克隆pyenv: 2. 配置环境变量 依次使用下面三个命令来配置环境变量: 或者直接进入该文件中,在末尾添加: 3. 使用环境变量 使用source命令重新执行上一步中修改的配置文件: 至

  • 无法上传/下载 检查 ccnet.conf 中SERVICE_URL的配置,检查 seahub_settings.py 中FILE_SERVER_ROOT的配置 确认防火墙没有禁用 seafile fileserver 使用 chrome/firefox 调试模式,找到点击下载按钮时使用的链接并查看错误信息。 Apache 日志文件报错: “File does not exist: /var/ww

  • 我试图在PyCharm中使用python,并为我的项目设置一个virtualenv。我想象的工作方式应该是,我建立一个项目,从一个存储库中提取。这是一个Django项目,所以我启用了Django支持。设置pyenv是有益的,所以我将解释器设置为使用pyenv。PyCharm应该包括pyenv,所以我不需要从我的操作系统安装它,我的印象是要么Django也有它,要么我可以从PyCharm安装它。 而

  • 1.2.6 资料:其他ROS版本安装 我们的教程采用的是ROS的最新版本noetic,不过noetic较之于之前的ROS版本变动较大且部分功能包还未更新,因此如果有需要(比如到后期实践阶段,由于部分重要的功能包还未更新,需要ROS降级),也会安装之前版本的ROS,在此,建议选用的版本是melodic或kinetic。 接下来,就以melodic为例演示ROS历史版本安装(当然先要准备与melodi

  • 我正在使用Python 3.6。5和pyenv。PIP10刚刚问世,但pyenv正在用PIP9.0创建我的新虚拟环境。3,我必须手动更新其中的每一个。真烦人。 我试图更新pyenv并重新安装Python版本(我希望它会有更新的pip版本,但没有。),但没有成功。 我应该等待pyenv端的更新还是遗漏了什么?