【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
参考链接:
https://github.com/pyenv/pyenv
分类:
Python-Basic
, Linux-Basic
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?