【ubuntu】安装pyenv

一、官网

    https://github.com/pyenv/pyenv

 

二、作用

    管理python版本和环境

 

三、安装

3.1、自动安装

1、一键安装

curl https://pyenv.run | bash

网要好,可能会下载失败

会下载四个插件

pyenv-doctor  pyenv-update  pyenv-virtualenv  python-build

 

2、配置环境变量

vim ~/.bashrc

加入如下配置

复制代码
# pyenv
# Load pyenv automatically by appending
# the following to 
# ~/.bash_profile if it exists, otherwise ~/.profile (for login shells)
# and ~/.bashrc (for interactive shells) :

export PYENV_ROOT="$HOME/.pyenv"
[[ -d $PYENV_ROOT/bin ]] && export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"

# Restart your shell for the changes to take effect.

# Load pyenv-virtualenv automatically by adding
# the following to ~/.bashrc:

eval "$(pyenv virtualenv-init -)"
复制代码

生效配置

source ~/.bashrc

 

 

3.2、手动安装

1、手动下发和编译插件(插件是可选项)

# Check out Pyenv where you want it installed. A good place to choose is $HOME/.pyenv (but you can install it somewhere else):

git clone https://github.com/pyenv/pyenv.git ~/.pyenv

 
# Optionally, try to compile a dynamic Bash extension to speed up Pyenv. Don't worry if it fails; Pyenv will still work normally:

cd ~/.pyenv && src/configure && make -C src

手动安装插件

# 我们的pyenv的安装目录是/.pyenv,所以我们需要把pyenv-virtualenv克隆到/.pyenv/plugins下,执行下面的命令
git clone https://github.com/pyenv/pyenv-virtualenv.git ~/.pyenv/plugins/pyenv-virtualenv

 

 

2、配置环境变量

vim ~/.bashrc

复制代码
# pyenv
# Load pyenv automatically by appending
# the following to 
# ~/.bash_profile if it exists, otherwise ~/.profile (for login shells)
# and ~/.bashrc (for interactive shells) :

export PYENV_ROOT="$HOME/.pyenv"
[[ -d $PYENV_ROOT/bin ]] && export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"

# Restart your shell for the changes to take effect.

# Load pyenv-virtualenv automatically by adding
# the following to ~/.bashrc:

# 可选, 装了插件就配置,没装就不用配置 eval
"$(pyenv virtualenv-init -)"
复制代码

生效配置

source ~/.bashrc

 

四、更新

4.1 命令更新

pyenv update

4.2 手动更新

# To upgrade to the latest development version of pyenv, use git pull:
cd $(pyenv root)
git pull

 

五、卸载

5.1 删除安装目录

rm -rf ~/.pyenv

 

5.2 删除环境变量配置

就是自己添加的环境变量

 

 

六、使用方法

见另一篇文章

https://www.cnblogs.com/fireblackman/p/18588623

 

 

参考链接:

pyenv安装python工具报错:“ERROR: The Python ssl extension was not compiled. Missing the OpenSSL lib?”-CSDN博客

https://github.com/pyenv/pyenv

 


 

posted @   代码诠释的世界  阅读(381)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?
点击右上角即可分享
微信分享提示