首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >python版本管理工具:pyenv

python版本管理工具:pyenv

作者头像
kevinfaith
发布2018-09-18 16:25:27
5730
发布2018-09-18 16:25:27
举报
文章被收录于专栏:kevin-blogkevin-blog
简介:

这几天在学习python,因为我学的是python3的语法,但是我ubuntu默认安装的是python2,我sqlmap需要的环境也是python2的,但是我需要python3的环境作为学习,这怎么办呢,经过查阅资料,学习,我发现了一个神器,python的版本管理工具:pyenv,他支持python多版本共存,并可以随时切换。且不会互相影响。

安装pyenv:
curl -L https://raw.githubusercontent.com/yyuu/pyenv-installer/master/bin/pyenv-installer | bash  

安装完毕会提醒:

# Load pyenv automatically by adding  
# the following to ~/.bash_profile:  

export PATH="/root/.pyenv/bin:$PATH"  
eval "$(pyenv init -)"  
eval "$(pyenv virtualenv-init -)" 

因为我用的是zsh,zsh没有设置是不会读取~/.bash_profile的,so

vi ~/.zshrc

在文档末粘贴:

export PATH="/root/.pyenv/bin:$PATH"  
eval "$(pyenv init -)"  
eval "$(pyenv virtualenv-init -)" 

:wq 保存退出!

source ~/.zshrc

重启一下配置文件,然后执行:

pyenv -h 

/home/blog/source/_posts ‹ruby-2.3.0›  $ pyenv -h                         130 ↵
Usage: pyenv <command> [<args>]

Some useful pyenv commands are:
   commands    List all available pyenv commands
   local       Set or show the local application-specific Python version
   global      Set or show the global Python version
   shell       Set or show the shell-specific Python version
   install     Install a Python version using python-build
   uninstall   Uninstall a specific Python version
   rehash      Rehash pyenv shims (run this after installing executables)
   version     Show the current Python version and its origin
   versions    List all Python versions available to pyenv
   which       Display the full path to an executable
   whence      List all Python versions that contain the given executable

See `pyenv help <command>' for information on a specific         command.    
For full documentation, see: https://github.com/pyenv/pyenv#readme

安装成功~

简单的介绍一下常用的命令:

pyenv install --list        //查看可安装的python版本
pyenv install 3.5.0       //安装python3.5.0
pyenv rehash                    //更新数据库,在安装 Python 或者其他带有可执行文件的模块之后,需要对数据库进行更新:
pyenv versions        //查看当前使用的python版本
pyevn  global  3.5.0       //切换python全局版本为3.5.0
pyenv uninstall  3.5.0     //删除python3.5.0   
本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2018-05-14,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 简介:
  • 安装pyenv:
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档