继续浏览精彩内容
慕课网APP
程序员的梦工厂
打开
继续
感谢您的支持,我会继续努力的
赞赏金额会直接到老师账户
将二维码发送给自己后长按识别
微信支付
支付宝支付

python多版本管理工具pyenv安装

这个名字没人起
关注TA
已关注
手记 271
粉丝 19
获赞 92

python多版本管理工具pyenv安装

1.作用

  管理python解释器、python版本、python的虚拟环境

  软件下载地址:https://github.com/pyenv/pyenv

2.pyenv软件包安装

a、配置yum源(配置文件内容如下)

vi   CentOS6-Base-163.repo

[base]

name=CentOS-$releasever - Base - 163.com

baseurl=http://mirrors.163.com/centos/6/os/$basearch/

enable=1

gpgcheck=0

gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6

 

#released updates

[updates]

name=CentOS-$releasever - Updates - 163.com

baseurl=http://mirrors.163.com/centos/6/updates/$basearch/

gpgcheck=0

enable=1

gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6

 

#additional packages that may be useful

[extras]

name=CentOS-$releasever - Extras - 163.com

baseurl=http://mirrors.163.com/centos/6/extras/$basearch/

gpgcheck=0

enable=1

gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6

 

#additional packages that extend functionality of existing packages

[centosplus]

name=CentOS-$releasever - Plus - 163.com

baseurl=http://mirrors.163.com/centos/6/centosplus/$basearch/

gpgcheck=0

enabled=1

gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6

 

#contrib - packages by Centos Users

[contrib]

name=CentOS-$releasever - Contrib - 163.com

baseurl=http://mirrors.163.com/centos/6/contrib/$basearch/

gpgcheck=0

enabled=1

gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6

b、安装git软件和依赖包

yum install git -y

yum -y install gcc make patch gdbm-devel openssl-devel sqlite-devel readline- devel zlib-devel bzip2-devel

c、创建用户

useradd python

passwd python

d、安装pyenv软件

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

e、配置环境变量

vim ~/.bash_profile

export PATH="/home/python/.pyenv/bin:$PATH"

eval "$(pyenv init -)"

eval "$(pyenv virtualenv-init -)"

1.1.2  3.使用pyenv软件安装和管理python

a、列出所有可用版本

    pyenv versions

b、安装指定python版本

   pyenv install 3.5.3 -v

pyenv install --list

pyenv install 3.5.3 –v

本地pyenv安装python包过程

/home/python/.pyenv

/home/python/.pyenv/cache---需手工建立,将pytho包放入目录

 

查看python版本

 python -V

c、创建一个目录让local捆绑在一个目录下

 pyenv versions

 * system (set by /home/python/.pyenv/version)

  3.5.3

  3.6.1

  3.6.3

  mkdir -p magedu/projects

  cd magedu/projects/

  pyenv local 3.5.3----------------#让python版本捆绑在一个目录下

  python -V

  Python 3.5.3

  cd-------#你看如果在其它目录,python版本就是系统默认的2.6,local登录基本做到隔离

  python -V

  Python 2.6.6


pyenv  virtualenv   3.6.3  mage363

pyenv  versions

  system

  3.5.3

  3.6.1

* 3.6.3 (set by /home/python/magedu/projects/web/.python-version)

  3.6.3/envs/mage363

* mage363 (set by /home/python/magedu/projects/web/.python-version)

pyenv  local mage363

(mage363) [python@python web]$




打开App,阅读手记
0人推荐
发表评论
随时随地看视频慕课网APP