Python多版本管理软件pyenv

Python多版本管理软件pyenv

Python多版本管理软件pyenv

Python多版本管理软件pyenv

Pyenv是什么

git地址:https://github.com/yyuu/pyenv
1.pyenv是python版本多功能切换工具,对系统无任何依赖关系和损坏.
2.能支持多个python版本
3.可以在多个python不同版本之间切换

安装部署

环境:
Centos7.0  阿里云
安装:
1.curl -L https://raw.githubusercontent.com/yyuu/pyenv-installer/master/bin/pyenv-installer | bash
2.修改配置/etc/profile文件,添加如下文件
export PATH="/root/.pyenv/bin:$PATH"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
3. source /etc/profile
更新pyenv版本:
pyenv update
删除pyenv:
只需要删掉目录就可以(注意是隐藏文件)
rm -fr ~/.pyenv

使用pyenv在CentOS7.1上安装python3.5.2

1.先解决依赖关系
yum -y install gcc patch make gdbm-devel openssl-devel sqlite-devel zlib-devel bzip2-devel readline-devel
2.下载python3.5.2压缩包
wget http://7d9qvq.com1.z0.glb.clouddn.com/Python-3.5.2.tgz
3.把下载的文件重命名移动到如下目录
[root@zm-test-ops-01 ~]# mkdir /root/.pyenv/cache
[root@zm-test-ops-01 ~]# mv Python-3.5.2.tar.gz /root/.pyenv/cache/

4.安装使用

安装
[root@zm-test-ops-01 ~]# pyenv version
system (set by /root/.pyenv/version)
[root@zm-test-ops-01 ~]# pyenv install 3.5.2
Installing Python-3.5.2...
Installed Python-3.5.2 to /root/.pyenv/versions/3.5.2

[root@zm-test-ops-01 ~]#
查看版本
[root@zm-test-ops-01 ~]# pyenv versions
* system (set by /root/.pyenv/version)
  3.5.2
[root@zm-test-ops-01 ~]#
测试验证
1.查看当前版本
[root@zm-test-ops-01 ~]# python
Python 2.7.5 (default, Jun 17 2014, 18:11:42)
[GCC 4.8.2 20140120 (Red Hat 4.8.2-16)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
2.切换到python 3.5.2
[root@zm-test-ops-01 ~]# pyenv local 3.5.2
3.查看版本
[root@zm-test-ops-01 ~]# python
Python 3.5.2 (default, Jul  4 2016, 12:10:29)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> print ('hello world')
hello world
>>>
4.删除3.5.2文件
[root@zm-test-ops-01 ~]# rm -rf ~/.python-version
5.查看python版本
[root@zm-test-ops-01 ~]# python
Python 2.7.5 (default, Jun 17 2014, 18:11:42)
[GCC 4.8.2 20140120 (Red Hat 4.8.2-16)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
[root@zm-test-ops-01 ~]#

使用pip安装jupyter

修改pip文件
[root@zm-test-ops-01 ~]# cat  ~/.pip/pip.conf
[global]
index-url = http://mirrors.aliyun.com/pypi/simple
trusted-host = mirrors.aliyun.com
[root@zm-test-ops-01 ~]#
[root@zm-test-ops-01 ~]# pip install jupyter
[root@zm-test-ops-01 ~]# jupyter-notebook --ip=0.0.0.0 --no-browser

See also