Python入门篇-pyenv安装及应用
作者:尹正杰
版权声明:原创作品,谢绝转载!否则将追究法律责任。
一.推荐Python相关书籍
1>.《Python Cookbook》
2>.《Learn Python The Hard Way》
3>.《Google's Python Class》
4>. 《简明Python教程》
二.Python创始人介绍
1>.荷兰人Guido van Rossum,2005年加入Google,2013年加入Dropbox;
2>.1989年,创立Python语言,1991年初发布第一个公开发行版本;
3>.他是英国BBC喜剧《Monty Python's Flying Circus》的忠实粉丝;
4>.Python哲学(如下图所示,在python解释器中输入“import this”,就可以看到python哲学啦~)
三.Python版本说明
1>.Python版本
Python2.x发展到2.7版本
Python官网对2.x版本进行倒计时的网站:https://pythonclock.org/
python3.x发展到3.7版本
Python官网对3.x版本始自2008年,3.5版本发布于2015年(如果你用Python的话建议选择大于或等于3.5级以上版本)
不要迷信版本,学会一个版本,好好学会一门语言,其他都不是问题。
2>.2.x和3.x的区别
1>.语句函数化,例如print(100,300),即打印出:“100 300”,但是2.x版本中意思是print语句打印元组,3.x中意思是函数的2个参数。
2>.整除,例如“1/2”和“1//2”,3.x版本中“/”为自然除。
3>.3.x中raw_input重命名为input,不再使用raw_input。
4>.round函数,在3.x中i.5的取整变为距离最近的偶数。
5>.字符串统一使用Unicode。
6>.异常的捕获,抛出的语法改变。
四.开发环境-Pyenv安装
1>.Pyenv概述
Pyenv是Python多版本管理工具(在也不怕升级python导致yum不可用啦~)
1>.支持管理Python解释器;
2>.支持管理Python版本;
3>.支持管理Python的虚拟环境;
官方网址:https://github.com/pyenv/pyenv
2>.安装Git工具
[root@node101.yinzhengjie.org.cn ~]# yum -y install git
Loaded plugins: fastestmirror
Determining fastest mirrors
epel/x86_64/metalink | 6.3 kB 00:00:00
* base: mirrors.aliyun.com
* epel: mirrors.tuna.tsinghua.edu.cn
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
base | 3.6 kB 00:00:00
epel | 4.7 kB 00:00:00
extras | 3.4 kB 00:00:00
mysql-connectors-community | 2.5 kB 00:00:00
mysql-tools-community | 2.5 kB 00:00:00
mysql56-community | 2.5 kB 00:00:00
updates | 3.4 kB 00:00:00
zabbix | 2.9 kB 00:00:00
zabbix-non-supported | 951 B 00:00:00
(1/3): epel/x86_64/updateinfo | 998 kB 00:00:01
(2/3): updates/7/x86_64/primary_db | 4.2 MB 00:00:01
(3/3): epel/x86_64/primary_db | 6.7 MB 00:00:06
Resolving Dependencies
--> Running transaction check
---> Package git.x86_64 0:1.8.3.1-20.el7 will be installed
--> Processing Dependency: perl-Git = 1.8.3.1-20.el7 for package: git-1.8.3.1-20.el7.x86_64
--> Processing Dependency: rsync for package: git-1.8.3.1-20.el7.x86_64
--> Processing Dependency: perl(Term::ReadKey) for package: git-1.8.3.1-20.el7.x86_64
--> Processing Dependency: perl(Git) for package: git-1.8.3.1-20.el7.x86_64
--> Processing Dependency: perl(Error) for package: git-1.8.3.1-20.el7.x86_64
--> Running transaction check
---> Package perl-Error.noarch 1:0.17020-2.el7 will be installed
---> Package perl-Git.noarch 0:1.8.3.1-20.el7 will be installed
---> Package perl-TermReadKey.x86_64 0:2.30-20.el7 will be installed
---> Package rsync.x86_64 0:3.1.2-6.el7_6.1 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
==================================================================================================================================================================================================================================
Package Arch Version Repository Size
==================================================================================================================================================================================================================================
Installing:
git x86_64 1.8.3.1-20.el7 updates 4.4 M
Installing for dependencies:
perl-Error noarch 1:0.17020-2.el7 base 32 k
perl-Git noarch 1.8.3.1-20.el7 updates 55 k
perl-TermReadKey x86_64 2.30-20.el7 base 31 k
rsync x86_64 3.1.2-6.el7_6.1 updates 404 k
Transaction Summary
==================================================================================================================================================================================================================================
Install 1 Package (+4 Dependent packages)
Total download size: 4.9 M
Installed size: 23 M
Downloading packages:
(1/5): perl-Error-0.17020-2.el7.noarch.rpm | 32 kB 00:00:00
(2/5): perl-Git-1.8.3.1-20.el7.noarch.rpm | 55 kB 00:00:00
(3/5): perl-TermReadKey-2.30-20.el7.x86_64.rpm | 31 kB 00:00:00
(4/5): rsync-3.1.2-6.el7_6.1.x86_64.rpm | 404 kB 00:00:00
(5/5): git-1.8.3.1-20.el7.x86_64.rpm | 4.4 MB 00:00:01
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 3.7 MB/s | 4.9 MB 00:00:01
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : 1:perl-Error-0.17020-2.el7.noarch 1/5
Installing : rsync-3.1.2-6.el7_6.1.x86_64 2/5
Installing : perl-TermReadKey-2.30-20.el7.x86_64 3/5
Installing : git-1.8.3.1-20.el7.x86_64 4/5
Installing : perl-Git-1.8.3.1-20.el7.noarch 5/5
Verifying : perl-Git-1.8.3.1-20.el7.noarch 1/5
Verifying : 1:perl-Error-0.17020-2.el7.noarch 2/5
Verifying : perl-TermReadKey-2.30-20.el7.x86_64 3/5
Verifying : git-1.8.3.1-20.el7.x86_64 4/5
Verifying : rsync-3.1.2-6.el7_6.1.x86_64 5/5
Installed:
git.x86_64 0:1.8.3.1-20.el7
Dependency Installed:
perl-Error.noarch 1:0.17020-2.el7 perl-Git.noarch 0:1.8.3.1-20.el7 perl-TermReadKey.x86_64 0:2.30-20.el7 rsync.x86_64 0:3.1.2-6.el7_6.1
Complete!
[root@node101.yinzhengjie.org.cn ~]#
3>.安装Python编译相关依赖
[root@node101.yinzhengjie.org.cn ~]# yum -y install gcc make patch gdbm-devel openssl-devel sqlite-devel readline-devel zlib-devel bzip2-devel libffi-devel
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* epel: mirrors.tuna.tsinghua.edu.cn
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
Package 1:make-3.82-23.el7.x86_64 already installed and latest version
Resolving Dependencies
--> Running transaction check
---> Package bzip2-devel.x86_64 0:1.0.6-13.el7 will be installed
---> Package gcc.x86_64 0:4.8.5-36.el7_6.2 will be installed
--> Processing Dependency: libgomp = 4.8.5-36.el7_6.2 for package: gcc-4.8.5-36.el7_6.2.x86_64
--> Processing Dependency: cpp = 4.8.5-36.el7_6.2 for package: gcc-4.8.5-36.el7_6.2.x86_64
--> Processing Dependency: libgcc >= 4.8.5-36.el7_6.2 for package: gcc-4.8.5-36.el7_6.2.x86_64
--> Processing Dependency: glibc-devel >= 2.2.90-12 for package: gcc-4.8.5-36.el7_6.2.x86_64
--> Processing Dependency: libmpfr.so.4()(64bit) for package: gcc-4.8.5-36.el7_6.2.x86_64
--> Processing Dependency: libmpc.so.3()(64bit) for package: gcc-4.8.5-36.el7_6.2.x86_64
---> Package gdbm-devel.x86_64 0:1.10-8.el7 will be installed
---> Package openssl-devel.x86_64 1:1.0.2k-16.el7_6.1 will be installed
--> Processing Dependency: openssl-libs(x86-64) = 1:1.0.2k-16.el7_6.1 for package: 1:openssl-devel-1.0.2k-16.el7_6.1.x86_64
--> Processing Dependency: krb5-devel(x86-64) for package: 1:openssl-devel-1.0.2k-16.el7_6.1.x86_64
---> Package patch.x86_64 0:2.7.1-10.el7_5 will be installed
---> Package readline-devel.x86_64 0:6.2-10.el7 will be installed
--> Processing Dependency: ncurses-devel for package: readline-devel-6.2-10.el7.x86_64
---> Package sqlite-devel.x86_64 0:3.7.17-8.el7 will be installed
---> Package zlib-devel.x86_64 0:1.2.7-18.el7 will be installed
--> Running transaction check
---> Package cpp.x86_64 0:4.8.5-36.el7_6.2 will be installed
---> Package glibc-devel.x86_64 0:2.17-260.el7_6.5 will be installed
--> Processing Dependency: glibc-headers = 2.17-260.el7_6.5 for package: glibc-devel-2.17-260.el7_6.5.x86_64
--> Processing Dependency: glibc = 2.17-260.el7_6.5 for package: glibc-devel-2.17-260.el7_6.5.x86_64
--> Processing Dependency: glibc-headers for package: glibc-devel-2.17-260.el7_6.5.x86_64
---> Package krb5-devel.x86_64 0:1.15.1-37.el7_6 will be installed
--> Processing Dependency: libkadm5(x86-64) = 1.15.1-37.el7_6 for package: krb5-devel-1.15.1-37.el7_6.x86_64
--> Processing Dependency: krb5-libs(x86-64) = 1.15.1-37.el7_6 for package: krb5-devel-1.15.1-37.el7_6.x86_64
--> Processing Dependency: libverto-devel for package: krb5-devel-1.15.1-37.el7_6.x86_64
--> Processing Dependency: libselinux-devel for package: krb5-devel-1.15.1-37.el7_6.x86_64
--> Processing Dependency: libcom_err-devel for package: krb5-devel-1.15.1-37.el7_6.x86_64
--> Processing Dependency: keyutils-libs-devel for package: krb5-devel-1.15.1-37.el7_6.x86_64
---> Package libgcc.x86_64 0:4.8.5-36.el7 will be updated
---> Package libgcc.x86_64 0:4.8.5-36.el7_6.2 will be an update
---> Package libgomp.x86_64 0:4.8.5-36.el7 will be updated
---> Package libgomp.x86_64 0:4.8.5-36.el7_6.2 will be an update
---> Package libmpc.x86_64 0:1.0.1-3.el7 will be installed
---> Package mpfr.x86_64 0:3.1.1-4.el7 will be installed
---> Package ncurses-devel.x86_64 0:5.9-14.20130511.el7_4 will be installed
---> Package openssl-libs.x86_64 1:1.0.2k-16.el7 will be updated
--> Processing Dependency: openssl-libs(x86-64) = 1:1.0.2k-16.el7 for package: 1:openssl-1.0.2k-16.el7.x86_64
---> Package openssl-libs.x86_64 1:1.0.2k-16.el7_6.1 will be an update
--> Running transaction check
---> Package glibc.x86_64 0:2.17-260.el7 will be updated
--> Processing Dependency: glibc = 2.17-260.el7 for package: glibc-common-2.17-260.el7.x86_64
---> Package glibc.x86_64 0:2.17-260.el7_6.5 will be an update
---> Package glibc-headers.x86_64 0:2.17-260.el7_6.5 will be installed
--> Processing Dependency: kernel-headers >= 2.2.1 for package: glibc-headers-2.17-260.el7_6.5.x86_64
--> Processing Dependency: kernel-headers for package: glibc-headers-2.17-260.el7_6.5.x86_64
---> Package keyutils-libs-devel.x86_64 0:1.5.8-3.el7 will be installed
---> Package krb5-libs.x86_64 0:1.15.1-34.el7 will be updated
---> Package krb5-libs.x86_64 0:1.15.1-37.el7_6 will be an update
---> Package libcom_err-devel.x86_64 0:1.42.9-13.el7 will be installed
---> Package libkadm5.x86_64 0:1.15.1-37.el7_6 will be installed
---> Package libselinux-devel.x86_64 0:2.5-14.1.el7 will be installed
--> Processing Dependency: libsepol-devel(x86-64) >= 2.5-10 for package: libselinux-devel-2.5-14.1.el7.x86_64
--> Processing Dependency: pkgconfig(libsepol) for package: libselinux-devel-2.5-14.1.el7.x86_64
--> Processing Dependency: pkgconfig(libpcre) for package: libselinux-devel-2.5-14.1.el7.x86_64
---> Package libverto-devel.x86_64 0:0.2.5-4.el7 will be installed
---> Package openssl.x86_64 1:1.0.2k-16.el7 will be updated
---> Package openssl.x86_64 1:1.0.2k-16.el7_6.1 will be an update
--> Running transaction check
---> Package glibc-common.x86_64 0:2.17-260.el7 will be updated
---> Package glibc-common.x86_64 0:2.17-260.el7_6.5 will be an update
---> Package kernel-headers.x86_64 0:3.10.0-957.12.1.el7 will be installed
---> Package libsepol-devel.x86_64 0:2.5-10.el7 will be installed
---> Package pcre-devel.x86_64 0:8.32-17.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
==================================================================================================================================================================================================================================
Package Arch Version Repository Size
==================================================================================================================================================================================================================================
Installing:
bzip2-devel x86_64 1.0.6-13.el7 base 218 k
gcc x86_64 4.8.5-36.el7_6.2 updates 16 M
gdbm-devel x86_64 1.10-8.el7 base 47 k
openssl-devel x86_64 1:1.0.2k-16.el7_6.1 updates 1.5 M
patch x86_64 2.7.1-10.el7_5 base 110 k
readline-devel x86_64 6.2-10.el7 base 138 k
sqlite-devel x86_64 3.7.17-8.el7 base 104 k
zlib-devel x86_64 1.2.7-18.el7 base 50 k
Installing for dependencies:
cpp x86_64 4.8.5-36.el7_6.2 updates 5.9 M
glibc-devel x86_64 2.17-260.el7_6.5 updates 1.1 M
glibc-headers x86_64 2.17-260.el7_6.5 updates 683 k
kernel-headers x86_64 3.10.0-957.12.1.el7 updates 8.0 M
keyutils-libs-devel x86_64 1.5.8-3.el7 base 37 k
krb5-devel x86_64 1.15.1-37.el7_6 updates 271 k
libcom_err-devel x86_64 1.42.9-13.el7 base 31 k
libkadm5 x86_64 1.15.1-37.el7_6 updates 178 k
libmpc x86_64 1.0.1-3.el7 base 51 k
libselinux-devel x86_64 2.5-14.1.el7 base 187 k
libsepol-devel x86_64 2.5-10.el7 base 77 k
libverto-devel x86_64 0.2.5-4.el7 base 12 k
mpfr x86_64 3.1.1-4.el7 base 203 k
ncurses-devel x86_64 5.9-14.20130511.el7_4 base 712 k
pcre-devel x86_64 8.32-17.el7 base 480 k
Updating for dependencies:
glibc x86_64 2.17-260.el7_6.5 updates 3.7 M
glibc-common x86_64 2.17-260.el7_6.5 updates 12 M
krb5-libs x86_64 1.15.1-37.el7_6 updates 803 k
libgcc x86_64 4.8.5-36.el7_6.2 updates 102 k
libgomp x86_64 4.8.5-36.el7_6.2 updates 158 k
openssl x86_64 1:1.0.2k-16.el7_6.1 updates 493 k
openssl-libs x86_64 1:1.0.2k-16.el7_6.1 updates 1.2 M
Transaction Summary
==================================================================================================================================================================================================================================
Install 8 Packages (+15 Dependent packages)
Upgrade ( 7 Dependent packages)
Total download size: 54 M
Downloading packages:
Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
(1/30): bzip2-devel-1.0.6-13.el7.x86_64.rpm | 218 kB 00:00:04
(2/30): gdbm-devel-1.10-8.el7.x86_64.rpm | 47 kB 00:00:05
(3/30): cpp-4.8.5-36.el7_6.2.x86_64.rpm | 5.9 MB 00:00:06
(4/30): gcc-4.8.5-36.el7_6.2.x86_64.rpm | 16 MB 00:00:06
(5/30): glibc-2.17-260.el7_6.5.x86_64.rpm | 3.7 MB 00:00:00
(6/30): glibc-devel-2.17-260.el7_6.5.x86_64.rpm | 1.1 MB 00:00:00
(7/30): glibc-headers-2.17-260.el7_6.5.x86_64.rpm | 683 kB 00:00:00
(8/30): keyutils-libs-devel-1.5.8-3.el7.x86_64.rpm | 37 kB 00:00:00
(9/30): kernel-headers-3.10.0-957.12.1.el7.x86_64.rpm | 8.0 MB 00:00:02
(10/30): glibc-common-2.17-260.el7_6.5.x86_64.rpm | 12 MB 00:00:03
(11/30): krb5-devel-1.15.1-37.el7_6.x86_64.rpm | 271 kB 00:00:00
(12/30): libgcc-4.8.5-36.el7_6.2.x86_64.rpm | 102 kB 00:00:00
(13/30): libcom_err-devel-1.42.9-13.el7.x86_64.rpm | 31 kB 00:00:00
(14/30): libgomp-4.8.5-36.el7_6.2.x86_64.rpm | 158 kB 00:00:00
(15/30): libkadm5-1.15.1-37.el7_6.x86_64.rpm | 178 kB 00:00:00
(16/30): krb5-libs-1.15.1-37.el7_6.x86_64.rpm | 803 kB 00:00:00
(17/30): libmpc-1.0.1-3.el7.x86_64.rpm | 51 kB 00:00:00
(18/30): libselinux-devel-2.5-14.1.el7.x86_64.rpm | 187 kB 00:00:00
(19/30): libsepol-devel-2.5-10.el7.x86_64.rpm | 77 kB 00:00:00
(20/30): libverto-devel-0.2.5-4.el7.x86_64.rpm | 12 kB 00:00:00
(21/30): mpfr-3.1.1-4.el7.x86_64.rpm | 203 kB 00:00:00
(22/30): ncurses-devel-5.9-14.20130511.el7_4.x86_64.rpm | 712 kB 00:00:00
(23/30): openssl-1.0.2k-16.el7_6.1.x86_64.rpm | 493 kB 00:00:00
(24/30): openssl-devel-1.0.2k-16.el7_6.1.x86_64.rpm | 1.5 MB 00:00:00
(25/30): patch-2.7.1-10.el7_5.x86_64.rpm | 110 kB 00:00:00
(26/30): openssl-libs-1.0.2k-16.el7_6.1.x86_64.rpm | 1.2 MB 00:00:00
(27/30): readline-devel-6.2-10.el7.x86_64.rpm | 138 kB 00:00:00
(28/30): sqlite-devel-3.7.17-8.el7.x86_64.rpm | 104 kB 00:00:00
(29/30): zlib-devel-1.2.7-18.el7.x86_64.rpm | 50 kB 00:00:00
(30/30): pcre-devel-8.32-17.el7.x86_64.rpm | 480 kB 00:00:02
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 4.0 MB/s | 54 MB 00:00:13
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Updating : libgcc-4.8.5-36.el7_6.2.x86_64 1/37
Updating : glibc-common-2.17-260.el7_6.5.x86_64 2/37
Updating : glibc-2.17-260.el7_6.5.x86_64 3/37
Updating : 1:openssl-libs-1.0.2k-16.el7_6.1.x86_64 4/37
Updating : krb5-libs-1.15.1-37.el7_6.x86_64 5/37
Installing : mpfr-3.1.1-4.el7.x86_64 6/37
Installing : libmpc-1.0.1-3.el7.x86_64 7/37
Installing : cpp-4.8.5-36.el7_6.2.x86_64 8/37
Installing : libkadm5-1.15.1-37.el7_6.x86_64 9/37
Updating : libgomp-4.8.5-36.el7_6.2.x86_64 10/37
Installing : libsepol-devel-2.5-10.el7.x86_64 11/37
Installing : ncurses-devel-5.9-14.20130511.el7_4.x86_64 12/37
Installing : zlib-devel-1.2.7-18.el7.x86_64 13/37
Installing : libverto-devel-0.2.5-4.el7.x86_64 14/37
Installing : libcom_err-devel-1.42.9-13.el7.x86_64 15/37
Installing : kernel-headers-3.10.0-957.12.1.el7.x86_64 16/37
Installing : glibc-headers-2.17-260.el7_6.5.x86_64 17/37
Installing : glibc-devel-2.17-260.el7_6.5.x86_64 18/37
Installing : pcre-devel-8.32-17.el7.x86_64 19/37
Installing : libselinux-devel-2.5-14.1.el7.x86_64 20/37
Installing : keyutils-libs-devel-1.5.8-3.el7.x86_64 21/37
Installing : krb5-devel-1.15.1-37.el7_6.x86_64 22/37
Installing : 1:openssl-devel-1.0.2k-16.el7_6.1.x86_64 23/37
Installing : gcc-4.8.5-36.el7_6.2.x86_64 24/37
Installing : readline-devel-6.2-10.el7.x86_64 25/37
Updating : 1:openssl-1.0.2k-16.el7_6.1.x86_64 26/37
Installing : patch-2.7.1-10.el7_5.x86_64 27/37
Installing : sqlite-devel-3.7.17-8.el7.x86_64 28/37
Installing : bzip2-devel-1.0.6-13.el7.x86_64 29/37
Installing : gdbm-devel-1.10-8.el7.x86_64 30/37
Cleanup : 1:openssl-1.0.2k-16.el7.x86_64 31/37
Cleanup : 1:openssl-libs-1.0.2k-16.el7.x86_64 32/37
Cleanup : krb5-libs-1.15.1-34.el7.x86_64 33/37
Cleanup : libgomp-4.8.5-36.el7.x86_64 34/37
Cleanup : glibc-common-2.17-260.el7.x86_64 35/37
Cleanup : glibc-2.17-260.el7.x86_64 36/37
Cleanup : libgcc-4.8.5-36.el7.x86_64 37/37
Verifying : keyutils-libs-devel-1.5.8-3.el7.x86_64 1/37
Verifying : pcre-devel-8.32-17.el7.x86_64 2/37
Verifying : readline-devel-6.2-10.el7.x86_64 3/37
Verifying : gcc-4.8.5-36.el7_6.2.x86_64 4/37
Verifying : kernel-headers-3.10.0-957.12.1.el7.x86_64 5/37
Verifying : gdbm-devel-1.10-8.el7.x86_64 6/37
Verifying : libcom_err-devel-1.42.9-13.el7.x86_64 7/37
Verifying : krb5-devel-1.15.1-37.el7_6.x86_64 8/37
Verifying : bzip2-devel-1.0.6-13.el7.x86_64 9/37
Verifying : libverto-devel-0.2.5-4.el7.x86_64 10/37
Verifying : zlib-devel-1.2.7-18.el7.x86_64 11/37
Verifying : krb5-libs-1.15.1-37.el7_6.x86_64 12/37
Verifying : ncurses-devel-5.9-14.20130511.el7_4.x86_64 13/37
Verifying : glibc-devel-2.17-260.el7_6.5.x86_64 14/37
Verifying : libgcc-4.8.5-36.el7_6.2.x86_64 15/37
Verifying : libgomp-4.8.5-36.el7_6.2.x86_64 16/37
Verifying : glibc-common-2.17-260.el7_6.5.x86_64 17/37
Verifying : glibc-2.17-260.el7_6.5.x86_64 18/37
Verifying : 1:openssl-1.0.2k-16.el7_6.1.x86_64 19/37
Verifying : sqlite-devel-3.7.17-8.el7.x86_64 20/37
Verifying : 1:openssl-libs-1.0.2k-16.el7_6.1.x86_64 21/37
Verifying : libmpc-1.0.1-3.el7.x86_64 22/37
Verifying : libsepol-devel-2.5-10.el7.x86_64 23/37
Verifying : 1:openssl-devel-1.0.2k-16.el7_6.1.x86_64 24/37
Verifying : libkadm5-1.15.1-37.el7_6.x86_64 25/37
Verifying : mpfr-3.1.1-4.el7.x86_64 26/37
Verifying : glibc-headers-2.17-260.el7_6.5.x86_64 27/37
Verifying : libselinux-devel-2.5-14.1.el7.x86_64 28/37
Verifying : cpp-4.8.5-36.el7_6.2.x86_64 29/37
Verifying : patch-2.7.1-10.el7_5.x86_64 30/37
Verifying : libgcc-4.8.5-36.el7.x86_64 31/37
Verifying : glibc-2.17-260.el7.x86_64 32/37
Verifying : 1:openssl-1.0.2k-16.el7.x86_64 33/37
Verifying : 1:openssl-libs-1.0.2k-16.el7.x86_64 34/37
Verifying : libgomp-4.8.5-36.el7.x86_64 35/37
Verifying : glibc-common-2.17-260.el7.x86_64 36/37
Verifying : krb5-libs-1.15.1-34.el7.x86_64 37/37
Installed:
bzip2-devel.x86_64 0:1.0.6-13.el7 gcc.x86_64 0:4.8.5-36.el7_6.2 gdbm-devel.x86_64 0:1.10-8.el7 openssl-devel.x86_64 1:1.0.2k-16.el7_6.1 patch.x86_64 0:2.7.1-10.el7_5 readline-devel.x86_64 0:6.2-10.el7
sqlite-devel.x86_64 0:3.7.17-8.el7 zlib-devel.x86_64 0:1.2.7-18.el7
Dependency Installed:
cpp.x86_64 0:4.8.5-36.el7_6.2 glibc-devel.x86_64 0:2.17-260.el7_6.5 glibc-headers.x86_64 0:2.17-260.el7_6.5 kernel-headers.x86_64 0:3.10.0-957.12.1.el7 keyutils-libs-devel.x86_64 0:1.5.8-3.el7
krb5-devel.x86_64 0:1.15.1-37.el7_6 libcom_err-devel.x86_64 0:1.42.9-13.el7 libkadm5.x86_64 0:1.15.1-37.el7_6 libmpc.x86_64 0:1.0.1-3.el7 libselinux-devel.x86_64 0:2.5-14.1.el7
libsepol-devel.x86_64 0:2.5-10.el7 libverto-devel.x86_64 0:0.2.5-4.el7 mpfr.x86_64 0:3.1.1-4.el7 ncurses-devel.x86_64 0:5.9-14.20130511.el7_4 pcre-devel.x86_64 0:8.32-17.el7
Dependency Updated:
glibc.x86_64 0:2.17-260.el7_6.5 glibc-common.x86_64 0:2.17-260.el7_6.5 krb5-libs.x86_64 0:1.15.1-37.el7_6 libgcc.x86_64 0:4.8.5-36.el7_6.2 libgomp.x86_64 0:4.8.5-36.el7_6.2 openssl.x86_64 1:1.0.2k-16.el7_6.1
openssl-libs.x86_64 1:1.0.2k-16.el7_6.1
Complete!
[root@node101.yinzhengjie.org.cn ~]#
4>.创建python用户
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# useradd python
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# id python
uid=1001(python) gid=1001(python) groups=1001(python)
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# su python
[python@node101.yinzhengjie.org.cn /root]$ cd
[python@node101.yinzhengjie.org.cn ~]$
[python@node101.yinzhengjie.org.cn ~]$
[python@node101.yinzhengjie.org.cn ~]$
5>.使用python用户登录后安装Pyenv
[python@node101.yinzhengjie.org.cn ~]$ curl -L https://raw.githubusercontent.com/pyenv/pyenv-installer/master/bin/pyenv-installer | bash
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 2446 100 2446 0 0 752 0 0:00:03 0:00:03 --:--:-- 752
Cloning into '/home/python/.pyenv'...
remote: Enumerating objects: 643, done.
remote: Counting objects: 100% (643/643), done.
remote: Compressing objects: 100% (484/484), done.
remote: Total 643 (delta 317), reused 244 (delta 68), pack-reused 0
Receiving objects: 100% (643/643), 371.66 KiB | 229.00 KiB/s, done.
Resolving deltas: 100% (317/317), done.
Cloning into '/home/python/.pyenv/plugins/pyenv-doctor'...
remote: Enumerating objects: 11, done.
remote: Counting objects: 100% (11/11), done.
remote: Compressing objects: 100% (9/9), done.
remote: Total 11 (delta 1), reused 4 (delta 0), pack-reused 0
Unpacking objects: 100% (11/11), done.
Cloning into '/home/python/.pyenv/plugins/pyenv-installer'...
remote: Enumerating objects: 16, done.
remote: Counting objects: 100% (16/16), done.
remote: Compressing objects: 100% (13/13), done.
remote: Total 16 (delta 1), reused 10 (delta 0), pack-reused 0
Unpacking objects: 100% (16/16), done.
Cloning into '/home/python/.pyenv/plugins/pyenv-update'...
remote: Enumerating objects: 10, done.
remote: Counting objects: 100% (10/10), done.
remote: Compressing objects: 100% (6/6), done.
remote: Total 10 (delta 1), reused 6 (delta 0), pack-reused 0
Unpacking objects: 100% (10/10), done.
Cloning into '/home/python/.pyenv/plugins/pyenv-virtualenv'...
remote: Enumerating objects: 57, done.
remote: Counting objects: 100% (57/57), done.
remote: Compressing objects: 100% (51/51), done.
remote: Total 57 (delta 11), reused 21 (delta 0), pack-reused 0
Unpacking objects: 100% (57/57), done.
Cloning into '/home/python/.pyenv/plugins/pyenv-which-ext'...
remote: Enumerating objects: 10, done.
remote: Counting objects: 100% (10/10), done.
remote: Compressing objects: 100% (6/6), done.
remote: Total 10 (delta 1), reused 6 (delta 0), pack-reused 0
Unpacking objects: 100% (10/10), done.
WARNING: seems you still have not added 'pyenv' to the load path.
# Load pyenv automatically by adding
# the following to ~/.bashrc:
export PATH="/home/python/.pyenv/bin:$PATH"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
[python@node101.yinzhengjie.org.cn ~]$
[python@node101.yinzhengjie.org.cn ~]$ ll ~/.pyenv/
total 176
drwxrwxr-x 2 python python 19 May 10 19:36 bin
-rw-rw-r-- 1 python python 26615 May 10 19:36 CHANGELOG.md
-rw-rw-r-- 1 python python 7522 May 10 19:36 COMMANDS.md
drwxrwxr-x 2 python python 59 May 10 19:36 completions
-rw-rw-r-- 1 python python 3390 May 10 19:36 CONDUCT.md
drwxrwxr-x 2 python python 4096 May 10 19:36 libexec
-rw-rw-r-- 1 python python 1092 May 10 19:36 LICENSE
-rw-rw-r-- 1 python python 836 May 10 19:36 Makefile
drwxrwxr-x 8 python python 154 May 10 19:36 plugins
drwxrwxr-x 4 python python 32 May 10 19:36 pyenv.d
-rw-rw-r-- 1 python python 15939 May 10 19:36 README.md
drwxrwxr-x 2 python python 92 May 10 19:36 src
-rw-rw-r-- 1 python python 104764 May 10 19:36 terminal_output.png
drwxrwxr-x 3 python python 4096 May 10 19:36 test
[python@node101.yinzhengjie.org.cn ~]$
6>.在python用户的“~/.bash_profile”添加Pyenv环境变量
[python@node101.yinzhengjie.org.cn ~]$ tail -3 ~/.bash_profile
export PATH="/home/python/.pyenv/bin:$PATH"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
[python@node101.yinzhengjie.org.cn ~]$
[python@node101.yinzhengjie.org.cn ~]$ source ~/.bash_profile
[python@node101.yinzhengjie.org.cn ~]$
7>.测试pyenv环境配置是否生效
[python@node101.yinzhengjie.org.cn ~]$ pyenv
pyenv 1.2.11
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
[python@node101.yinzhengjie.org.cn ~]$
[python@node101.yinzhengjie.org.cn ~]$
五.Pyenv使用案例-install安装Python 3.6.6版本
1>.查看Pyenv的帮助信息
[python@node101.yinzhengjie.org.cn ~]$ pyenv help install
Usage: pyenv install [-f] [-kvp] <version>
pyenv install [-f] [-kvp] <definition-file>
pyenv install -l|--list
pyenv install --version
-l/--list List all available versions
-f/--force Install even if the version appears to be installed already
-s/--skip-existing Skip if the version appears to be installed already
python-build options:
-k/--keep Keep source tree in $PYENV_BUILD_ROOT after installation
(defaults to $PYENV_ROOT/sources)
-p/--patch Apply a patch from stdin before building
-v/--verbose Verbose mode: print compilation status to stdout
--version Show version of python-build
-g/--debug Build a debug version
For detailed information on installing Python versions with
python-build, including a list of environment variables for adjusting
compilation, see: https://github.com/pyenv/pyenv#readme
[python@node101.yinzhengjie.org.cn ~]$
[python@node101.yinzhengjie.org.cn ~]$
2>.列出所有Pyenv所有可用版本
[python@node101.yinzhengjie.org.cn ~]$ pyenv install --list
Available versions:
2.1.3
2.2.3
2.3.7
2.4.0
2.4.1
2.4.2
2.4.3
2.4.4
2.4.5
2.4.6
2.5.0
2.5.1
2.5.2
2.5.3
2.5.4
2.5.5
2.5.6
2.6.6
2.6.7
2.6.8
2.6.9
2.7.0
2.7-dev
2.7.1
2.7.2
2.7.3
2.7.4
2.7.5
2.7.6
2.7.7
2.7.8
2.7.9
2.7.10
2.7.11
2.7.12
2.7.13
2.7.14
2.7.15
2.7.16
3.0.1
3.1.0
3.1.1
3.1.2
3.1.3
3.1.4
3.1.5
3.2.0
3.2.1
3.2.2
3.2.3
3.2.4
3.2.5
3.2.6
3.3.0
3.3.1
3.3.2
3.3.3
3.3.4
3.3.5
3.3.6
3.3.7
3.4.0
3.4-dev
3.4.1
3.4.2
3.4.3
3.4.4
3.4.5
3.4.6
3.4.7
3.4.8
3.4.9
3.4.10
3.5.0
3.5-dev
3.5.1
3.5.2
3.5.3
3.5.4
3.5.5
3.5.6
3.5.7
3.6.0
3.6-dev
3.6.1
3.6.2
3.6.3
3.6.4
3.6.5
3.6.6
3.6.7
3.6.8
3.7.0
3.7-dev
3.7.1
3.7.2
3.7.3
3.8-dev
activepython-2.7.14
activepython-3.5.4
activepython-3.6.0
anaconda-1.4.0
anaconda-1.5.0
anaconda-1.5.1
anaconda-1.6.0
anaconda-1.6.1
anaconda-1.7.0
anaconda-1.8.0
anaconda-1.9.0
anaconda-1.9.1
anaconda-1.9.2
anaconda-2.0.0
anaconda-2.0.1
anaconda-2.1.0
anaconda-2.2.0
anaconda-2.3.0
anaconda-2.4.0
anaconda-4.0.0
anaconda2-2.4.0
anaconda2-2.4.1
anaconda2-2.5.0
anaconda2-4.0.0
anaconda2-4.1.0
anaconda2-4.1.1
anaconda2-4.2.0
anaconda2-4.3.0
anaconda2-4.3.1
anaconda2-4.4.0
anaconda2-5.0.0
anaconda2-5.0.1
anaconda2-5.1.0
anaconda2-5.2.0
anaconda2-5.3.0
anaconda2-5.3.1
anaconda2-2018.12
anaconda2-2019.03
anaconda3-2.0.0
anaconda3-2.0.1
anaconda3-2.1.0
anaconda3-2.2.0
anaconda3-2.3.0
anaconda3-2.4.0
anaconda3-2.4.1
anaconda3-2.5.0
anaconda3-4.0.0
anaconda3-4.1.0
anaconda3-4.1.1
anaconda3-4.2.0
anaconda3-4.3.0
anaconda3-4.3.1
anaconda3-4.4.0
anaconda3-5.0.0
anaconda3-5.0.1
anaconda3-5.1.0
anaconda3-5.2.0
anaconda3-5.3.0
anaconda3-5.3.1
anaconda3-2018.12
anaconda3-2019.03
ironpython-dev
ironpython-2.7.4
ironpython-2.7.5
ironpython-2.7.6.3
ironpython-2.7.7
jython-dev
jython-2.5.0
jython-2.5-dev
jython-2.5.1
jython-2.5.2
jython-2.5.3
jython-2.5.4-rc1
jython-2.7.0
jython-2.7.1
micropython-dev
micropython-1.9.3
micropython-1.9.4
micropython-1.10
miniconda-latest
miniconda-2.2.2
miniconda-3.0.0
miniconda-3.0.4
miniconda-3.0.5
miniconda-3.3.0
miniconda-3.4.2
miniconda-3.7.0
miniconda-3.8.3
miniconda-3.9.1
miniconda-3.10.1
miniconda-3.16.0
miniconda-3.18.3
miniconda2-latest
miniconda2-3.18.3
miniconda2-3.19.0
miniconda2-4.0.5
miniconda2-4.1.11
miniconda2-4.3.14
miniconda2-4.3.21
miniconda2-4.3.27
miniconda2-4.3.30
miniconda3-latest
miniconda3-2.2.2
miniconda3-3.0.0
miniconda3-3.0.4
miniconda3-3.0.5
miniconda3-3.3.0
miniconda3-3.4.2
miniconda3-3.7.0
miniconda3-3.8.3
miniconda3-3.9.1
miniconda3-3.10.1
miniconda3-3.16.0
miniconda3-3.18.3
miniconda3-3.19.0
miniconda3-4.0.5
miniconda3-4.1.11
miniconda3-4.2.12
miniconda3-4.3.11
miniconda3-4.3.14
miniconda3-4.3.21
miniconda3-4.3.27
miniconda3-4.3.30
pypy-c-jit-latest
pypy-c-nojit-latest
pypy-dev
pypy-stm-2.3
pypy-stm-2.5.1
pypy-1.5-src
pypy-1.5
pypy-1.6
pypy-1.7
pypy-1.8
pypy-1.9
pypy-2.0-src
pypy-2.0
pypy-2.0.1-src
pypy-2.0.1
pypy-2.0.2-src
pypy-2.0.2
pypy-2.1-src
pypy-2.1
pypy-2.2-src
pypy-2.2
pypy-2.2.1-src
pypy-2.2.1
pypy-2.3-src
pypy-2.3
pypy-2.3.1-src
pypy-2.3.1
pypy-2.4.0-src
pypy-2.4.0
pypy-2.5.0-src
pypy-2.5.0
pypy-2.5.1-src
pypy-2.5.1
pypy-2.6.0-src
pypy-2.6.0
pypy-2.6.1-src
pypy-2.6.1
pypy-4.0.0-src
pypy-4.0.0
pypy-4.0.1-src
pypy-4.0.1
pypy-5.0.0-src
pypy-5.0.0
pypy-5.0.1-src
pypy-5.0.1
pypy-5.1-src
pypy-5.1
pypy-5.1.1-src
pypy-5.1.1
pypy-5.3-src
pypy-5.3
pypy-5.3.1-src
pypy-5.3.1
pypy-5.4-src
pypy-5.4
pypy-5.4.1-src
pypy-5.4.1
pypy-5.6.0-src
pypy-5.6.0
pypy-5.7.0-src
pypy-5.7.0
pypy-5.7.1-src
pypy-5.7.1
pypy2-5.3-src
pypy2-5.3
pypy2-5.3.1-src
pypy2-5.3.1
pypy2-5.4-src
pypy2-5.4
pypy2-5.4.1-src
pypy2-5.4.1
pypy2-5.6.0-src
pypy2-5.6.0
pypy2-5.7.0-src
pypy2-5.7.0
pypy2-5.7.1-src
pypy2-5.7.1
pypy2.7-5.8.0-src
pypy2.7-5.8.0
pypy2.7-5.9.0-src
pypy2.7-5.9.0
pypy2.7-5.10.0-src
pypy2.7-5.10.0
pypy2.7-6.0.0-src
pypy2.7-6.0.0
pypy2.7-7.0.0-src
pypy2.7-7.0.0
pypy2.7-7.1.0-src
pypy2.7-7.1.0
pypy2.7-7.1.1-src
pypy2.7-7.1.1
pypy3-dev
pypy3-2.3.1-src
pypy3-2.3.1
pypy3-2.4.0-src
pypy3-2.4.0
pypy3.3-5.2-alpha1-src
pypy3.3-5.2-alpha1
pypy3.3-5.5-alpha-src
pypy3.3-5.5-alpha
pypy3.5-c-jit-latest
pypy3.5-5.7-beta-src
pypy3.5-5.7-beta
pypy3.5-5.7.1-beta-src
pypy3.5-5.7.1-beta
pypy3.5-5.8.0-src
pypy3.5-5.8.0
pypy3.5-5.9.0-src
pypy3.5-5.9.0
pypy3.5-5.10.0-src
pypy3.5-5.10.0
pypy3.5-5.10.1-src
pypy3.5-5.10.1
pypy3.5-6.0.0-src
pypy3.5-6.0.0
pypy3.5-7.0.0-src
pypy3.5-7.0.0
pypy3.6-7.0.0-src
pypy3.6-7.0.0
pypy3.6-7.1.0-src
pypy3.6-7.1.0
pypy3.6-7.1.1-src
pypy3.6-7.1.1
pyston-0.5.1
pyston-0.6.0
pyston-0.6.1
stackless-dev
stackless-2.7-dev
stackless-2.7.2
stackless-2.7.3
stackless-2.7.4
stackless-2.7.5
stackless-2.7.6
stackless-2.7.7
stackless-2.7.8
stackless-2.7.9
stackless-2.7.10
stackless-2.7.11
stackless-2.7.12
stackless-2.7.14
stackless-3.2.2
stackless-3.2.5
stackless-3.3.5
stackless-3.3.7
stackless-3.4-dev
stackless-3.4.1
stackless-3.4.2
stackless-3.4.7
stackless-3.5.4
[python@node101.yinzhengjie.org.cn ~]$
[python@node101.yinzhengjie.org.cn ~]$ pyenv install -l
Available versions:
2.1.3
2.2.3
2.3.7
2.4.0
2.4.1
2.4.2
2.4.3
2.4.4
2.4.5
2.4.6
2.5.0
2.5.1
2.5.2
2.5.3
2.5.4
2.5.5
2.5.6
2.6.6
2.6.7
2.6.8
2.6.9
2.7.0
2.7-dev
2.7.1
2.7.2
2.7.3
2.7.4
2.7.5
2.7.6
2.7.7
2.7.8
2.7.9
2.7.10
2.7.11
2.7.12
2.7.13
2.7.14
2.7.15
2.7.16
3.0.1
3.1.0
3.1.1
3.1.2
3.1.3
3.1.4
3.1.5
3.2.0
3.2.1
3.2.2
3.2.3
3.2.4
3.2.5
3.2.6
3.3.0
3.3.1
3.3.2
3.3.3
3.3.4
3.3.5
3.3.6
3.3.7
3.4.0
3.4-dev
3.4.1
3.4.2
3.4.3
3.4.4
3.4.5
3.4.6
3.4.7
3.4.8
3.4.9
3.4.10
3.5.0
3.5-dev
3.5.1
3.5.2
3.5.3
3.5.4
3.5.5
3.5.6
3.5.7
3.6.0
3.6-dev
3.6.1
3.6.2
3.6.3
3.6.4
3.6.5
3.6.6
3.6.7
3.6.8
3.7.0
3.7-dev
3.7.1
3.7.2
3.7.3
3.8-dev
activepython-2.7.14
activepython-3.5.4
activepython-3.6.0
anaconda-1.4.0
anaconda-1.5.0
anaconda-1.5.1
anaconda-1.6.0
anaconda-1.6.1
anaconda-1.7.0
anaconda-1.8.0
anaconda-1.9.0
anaconda-1.9.1
anaconda-1.9.2
anaconda-2.0.0
anaconda-2.0.1
anaconda-2.1.0
anaconda-2.2.0
anaconda-2.3.0
anaconda-2.4.0
anaconda-4.0.0
anaconda2-2.4.0
anaconda2-2.4.1
anaconda2-2.5.0
anaconda2-4.0.0
anaconda2-4.1.0
anaconda2-4.1.1
anaconda2-4.2.0
anaconda2-4.3.0
anaconda2-4.3.1
anaconda2-4.4.0
anaconda2-5.0.0
anaconda2-5.0.1
anaconda2-5.1.0
anaconda2-5.2.0
anaconda2-5.3.0
anaconda2-5.3.1
anaconda2-2018.12
anaconda2-2019.03
anaconda3-2.0.0
anaconda3-2.0.1
anaconda3-2.1.0
anaconda3-2.2.0
anaconda3-2.3.0
anaconda3-2.4.0
anaconda3-2.4.1
anaconda3-2.5.0
anaconda3-4.0.0
anaconda3-4.1.0
anaconda3-4.1.1
anaconda3-4.2.0
anaconda3-4.3.0
anaconda3-4.3.1
anaconda3-4.4.0
anaconda3-5.0.0
anaconda3-5.0.1
anaconda3-5.1.0
anaconda3-5.2.0
anaconda3-5.3.0
anaconda3-5.3.1
anaconda3-2018.12
anaconda3-2019.03
ironpython-dev
ironpython-2.7.4
ironpython-2.7.5
ironpython-2.7.6.3
ironpython-2.7.7
jython-dev
jython-2.5.0
jython-2.5-dev
jython-2.5.1
jython-2.5.2
jython-2.5.3
jython-2.5.4-rc1
jython-2.7.0
jython-2.7.1
micropython-dev
micropython-1.9.3
micropython-1.9.4
micropython-1.10
miniconda-latest
miniconda-2.2.2
miniconda-3.0.0
miniconda-3.0.4
miniconda-3.0.5
miniconda-3.3.0
miniconda-3.4.2
miniconda-3.7.0
miniconda-3.8.3
miniconda-3.9.1
miniconda-3.10.1
miniconda-3.16.0
miniconda-3.18.3
miniconda2-latest
miniconda2-3.18.3
miniconda2-3.19.0
miniconda2-4.0.5
miniconda2-4.1.11
miniconda2-4.3.14
miniconda2-4.3.21
miniconda2-4.3.27
miniconda2-4.3.30
miniconda3-latest
miniconda3-2.2.2
miniconda3-3.0.0
miniconda3-3.0.4
miniconda3-3.0.5
miniconda3-3.3.0
miniconda3-3.4.2
miniconda3-3.7.0
miniconda3-3.8.3
miniconda3-3.9.1
miniconda3-3.10.1
miniconda3-3.16.0
miniconda3-3.18.3
miniconda3-3.19.0
miniconda3-4.0.5
miniconda3-4.1.11
miniconda3-4.2.12
miniconda3-4.3.11
miniconda3-4.3.14
miniconda3-4.3.21
miniconda3-4.3.27
miniconda3-4.3.30
pypy-c-jit-latest
pypy-c-nojit-latest
pypy-dev
pypy-stm-2.3
pypy-stm-2.5.1
pypy-1.5-src
pypy-1.5
pypy-1.6
pypy-1.7
pypy-1.8
pypy-1.9
pypy-2.0-src
pypy-2.0
pypy-2.0.1-src
pypy-2.0.1
pypy-2.0.2-src
pypy-2.0.2
pypy-2.1-src
pypy-2.1
pypy-2.2-src
pypy-2.2
pypy-2.2.1-src
pypy-2.2.1
pypy-2.3-src
pypy-2.3
pypy-2.3.1-src
pypy-2.3.1
pypy-2.4.0-src
pypy-2.4.0
pypy-2.5.0-src
pypy-2.5.0
pypy-2.5.1-src
pypy-2.5.1
pypy-2.6.0-src
pypy-2.6.0
pypy-2.6.1-src
pypy-2.6.1
pypy-4.0.0-src
pypy-4.0.0
pypy-4.0.1-src
pypy-4.0.1
pypy-5.0.0-src
pypy-5.0.0
pypy-5.0.1-src
pypy-5.0.1
pypy-5.1-src
pypy-5.1
pypy-5.1.1-src
pypy-5.1.1
pypy-5.3-src
pypy-5.3
pypy-5.3.1-src
pypy-5.3.1
pypy-5.4-src
pypy-5.4
pypy-5.4.1-src
pypy-5.4.1
pypy-5.6.0-src
pypy-5.6.0
pypy-5.7.0-src
pypy-5.7.0
pypy-5.7.1-src
pypy-5.7.1
pypy2-5.3-src
pypy2-5.3
pypy2-5.3.1-src
pypy2-5.3.1
pypy2-5.4-src
pypy2-5.4
pypy2-5.4.1-src
pypy2-5.4.1
pypy2-5.6.0-src
pypy2-5.6.0
pypy2-5.7.0-src
pypy2-5.7.0
pypy2-5.7.1-src
pypy2-5.7.1
pypy2.7-5.8.0-src
pypy2.7-5.8.0
pypy2.7-5.9.0-src
pypy2.7-5.9.0
pypy2.7-5.10.0-src
pypy2.7-5.10.0
pypy2.7-6.0.0-src
pypy2.7-6.0.0
pypy2.7-7.0.0-src
pypy2.7-7.0.0
pypy2.7-7.1.0-src
pypy2.7-7.1.0
pypy2.7-7.1.1-src
pypy2.7-7.1.1
pypy3-dev
pypy3-2.3.1-src
pypy3-2.3.1
pypy3-2.4.0-src
pypy3-2.4.0
pypy3.3-5.2-alpha1-src
pypy3.3-5.2-alpha1
pypy3.3-5.5-alpha-src
pypy3.3-5.5-alpha
pypy3.5-c-jit-latest
pypy3.5-5.7-beta-src
pypy3.5-5.7-beta
pypy3.5-5.7.1-beta-src
pypy3.5-5.7.1-beta
pypy3.5-5.8.0-src
pypy3.5-5.8.0
pypy3.5-5.9.0-src
pypy3.5-5.9.0
pypy3.5-5.10.0-src
pypy3.5-5.10.0
pypy3.5-5.10.1-src
pypy3.5-5.10.1
pypy3.5-6.0.0-src
pypy3.5-6.0.0
pypy3.5-7.0.0-src
pypy3.5-7.0.0
pypy3.6-7.0.0-src
pypy3.6-7.0.0
pypy3.6-7.1.0-src
pypy3.6-7.1.0
pypy3.6-7.1.1-src
pypy3.6-7.1.1
pyston-0.5.1
pyston-0.6.0
pyston-0.6.1
stackless-dev
stackless-2.7-dev
stackless-2.7.2
stackless-2.7.3
stackless-2.7.4
stackless-2.7.5
stackless-2.7.6
stackless-2.7.7
stackless-2.7.8
stackless-2.7.9
stackless-2.7.10
stackless-2.7.11
stackless-2.7.12
stackless-2.7.14
stackless-3.2.2
stackless-3.2.5
stackless-3.3.5
stackless-3.3.7
stackless-3.4-dev
stackless-3.4.1
stackless-3.4.2
stackless-3.4.7
stackless-3.5.4
[python@node101.yinzhengjie.org.cn ~]$
3>.使用pyenv查看当前版本
[python@node101.yinzhengjie.org.cn ~]$ python -V #这是我们在Linux操作系统身上使用python命令查看Python版本。是默认CentOS7.6默认安装的版本。
Python 2.7.5
[python@node101.yinzhengjie.org.cn ~]$
[python@node101.yinzhengjie.org.cn ~]$ pyenv version #我们使用pyenv命令查看当前Python版本,它告诉我们说是当前版本为系统版本。
system (set by /home/python/.pyenv/version)
[python@node101.yinzhengjie.org.cn ~]$
[python@node101.yinzhengjie.org.cn ~]$ pyenv versions #查看当前环境所有的Python版本,因为我们到目前为止除了系统版本外还没有安装任何Python版本!因此我们只能看到系统版本版本哟~想看到其他版本咱们自行安装即可!
* system (set by /home/python/.pyenv/version)
[python@node101.yinzhengjie.org.cn ~]$
4>.在线安装指定python版本(不推荐使用,因为在线安装带宽存在不稳定因素)
[python@node101.yinzhengjie.org.cn ~]$ pyenv install 3.6.6 -v
/tmp/python-build.20190510195824.14876 ~
Downloading Python-3.6.6.tar.xz...
-> https://www.python.org/ftp/python/3.6.6/Python-3.6.6.tar.xz
^Cerror: failed to download Python-3.6.6.tar.xz
BUILD FAILED (CentOS Linux 7 using python-build 20180424)
Inspect or clean up the working tree at /tmp/python-build.20190510195824.14876
Results logged to /tmp/python-build.20190510195824.14876.log
Last 10 log lines:
/tmp/python-build.20190510195824.14876 ~
/home/python/.pyenv/plugins/python-build/bin/p
5>.使用缓存方式安装python版本
[python@node101.yinzhengjie.org.cn ~]$ ll .pyenv/
total 176
drwxrwxr-x 2 python python 19 May 10 19:36 bin
-rw-rw-r-- 1 python python 26615 May 10 19:36 CHANGELOG.md
-rw-rw-r-- 1 python python 7522 May 10 19:36 COMMANDS.md
drwxrwxr-x 2 python python 59 May 10 19:36 completions
-rw-rw-r-- 1 python python 3390 May 10 19:36 CONDUCT.md
drwxrwxr-x 2 python python 4096 May 10 19:36 libexec
-rw-rw-r-- 1 python python 1092 May 10 19:36 LICENSE
-rw-rw-r-- 1 python python 836 May 10 19:36 Makefile
drwxrwxr-x 8 python python 154 May 10 19:36 plugins
drwxrwxr-x 4 python python 32 May 10 19:36 pyenv.d
-rw-rw-r-- 1 python python 15939 May 10 19:36 README.md
drwxrwxr-x 2 python python 6 May 10 19:42 shims
drwxrwxr-x 2 python python 92 May 10 19:36 src
-rw-rw-r-- 1 python python 104764 May 10 19:36 terminal_output.png
drwxrwxr-x 3 python python 4096 May 10 19:36 test
drwxrwxr-x 2 python python 6 May 10 19:42 versions
[python@node101.yinzhengjie.org.cn ~]$
[python@node101.yinzhengjie.org.cn ~]$
[python@node101.yinzhengjie.org.cn ~]$ mkdir .pyenv/cache
[python@node101.yinzhengjie.org.cn ~]$
[python@node101.yinzhengjie.org.cn ~]$ ll .pyenv/
total 176
drwxrwxr-x 2 python python 19 May 10 19:36 bin
drwxrwxr-x 2 python python 6 May 10 20:07 cache
-rw-rw-r-- 1 python python 26615 May 10 19:36 CHANGELOG.md
-rw-rw-r-- 1 python python 7522 May 10 19:36 COMMANDS.md
drwxrwxr-x 2 python python 59 May 10 19:36 completions
-rw-rw-r-- 1 python python 3390 May 10 19:36 CONDUCT.md
drwxrwxr-x 2 python python 4096 May 10 19:36 libexec
-rw-rw-r-- 1 python python 1092 May 10 19:36 LICENSE
-rw-rw-r-- 1 python python 836 May 10 19:36 Makefile
drwxrwxr-x 8 python python 154 May 10 19:36 plugins
drwxrwxr-x 4 python python 32 May 10 19:36 pyenv.d
-rw-rw-r-- 1 python python 15939 May 10 19:36 README.md
drwxrwxr-x 2 python python 6 May 10 19:42 shims
drwxrwxr-x 2 python python 92 May 10 19:36 src
-rw-rw-r-- 1 python python 104764 May 10 19:36 terminal_output.png
drwxrwxr-x 3 python python 4096 May 10 19:36 test
drwxrwxr-x 2 python python 6 May 10 19:42 versions
[python@node101.yinzhengjie.org.cn ~]$
[python@node101.yinzhengjie.org.cn ~]$ ll ~/.pyenv/cache/
total 39152
-rw-r--r-- 1 python python 17156744 May 10 20:11 Python-3.6.6.tar.xz
-rw-r--r-- 1 python python 22930752 May 10 20:09 Python-3.6.6.tgz
[python@node101.yinzhengjie.org.cn ~]$
[python@node101.yinzhengjie.org.cn ~]$
[python@node101.yinzhengjie.org.cn ~/.pyenv/cache]$ ll
total 39152
-rw-r--r-- 1 python python 17156744 May 10 20:11 Python-3.6.6.tar.xz
-rw-r--r-- 1 python python 22930752 May 10 20:09 Python-3.6.6.tgz
[python@node101.yinzhengjie.org.cn ~/.pyenv/cache]$
[python@node101.yinzhengjie.org.cn ~/.pyenv/cache]$
[python@node101.yinzhengjie.org.cn ~/.pyenv/cache]$ pyenv install 3.6.6 -v
......
changing mode of /home/python/.pyenv/versions/3.6.6/lib/python3.6/lib-dynload/mmap.cpython-36m-x86_64-linux-gnu.so to 755
changing mode of /home/python/.pyenv/versions/3.6.6/lib/python3.6/lib-dynload/readline.cpython-36m-x86_64-linux-gnu.so to 755
changing mode of /home/python/.pyenv/versions/3.6.6/lib/python3.6/lib-dynload/_crypt.cpython-36m-x86_64-linux-gnu.so to 755
changing mode of /home/python/.pyenv/versions/3.6.6/lib/python3.6/lib-dynload/audioop.cpython-36m-x86_64-linux-gnu.so to 755
changing mode of /home/python/.pyenv/versions/3.6.6/lib/python3.6/lib-dynload/_posixsubprocess.cpython-36m-x86_64-linux-gnu.so to 755
changing mode of /home/python/.pyenv/versions/3.6.6/lib/python3.6/lib-dynload/_csv.cpython-36m-x86_64-linux-gnu.so to 755
changing mode of /home/python/.pyenv/versions/3.6.6/lib/python3.6/lib-dynload/_ssl.cpython-36m-x86_64-linux-gnu.so to 755
changing mode of /home/python/.pyenv/versions/3.6.6/lib/python3.6/lib-dynload/_socket.cpython-36m-x86_64-linux-gnu.so to 755
changing mode of /home/python/.pyenv/versions/3.6.6/lib/python3.6/lib-dynload/_hashlib.cpython-36m-x86_64-linux-gnu.so to 755
changing mode of /home/python/.pyenv/versions/3.6.6/lib/python3.6/lib-dynload/_sha256.cpython-36m-x86_64-linux-gnu.so to 755
changing mode of /home/python/.pyenv/versions/3.6.6/lib/python3.6/lib-dynload/_md5.cpython-36m-x86_64-linux-gnu.so to 755
changing mode of /home/python/.pyenv/versions/3.6.6/lib/python3.6/lib-dynload/_sha1.cpython-36m-x86_64-linux-gnu.so to 755
changing mode of /home/python/.pyenv/versions/3.6.6/lib/python3.6/lib-dynload/_sha512.cpython-36m-x86_64-linux-gnu.so to 755
changing mode of /home/python/.pyenv/versions/3.6.6/lib/python3.6/lib-dynload/_blake2.cpython-36m-x86_64-linux-gnu.so to 755
changing mode of /home/python/.pyenv/versions/3.6.6/lib/python3.6/lib-dynload/_sqlite3.cpython-36m-x86_64-linux-gnu.so to 755
changing mode of /home/python/.pyenv/versions/3.6.6/lib/python3.6/lib-dynload/_dbm.cpython-36m-x86_64-linux-gnu.so to 755
changing mode of /home/python/.pyenv/versions/3.6.6/lib/python3.6/lib-dynload/_sha3.cpython-36m-x86_64-linux-gnu.so to 755
changing mode of /home/python/.pyenv/versions/3.6.6/lib/python3.6/lib-dynload/_gdbm.cpython-36m-x86_64-linux-gnu.so to 755
changing mode of /home/python/.pyenv/versions/3.6.6/lib/python3.6/lib-dynload/termios.cpython-36m-x86_64-linux-gnu.so to 755
changing mode of /home/python/.pyenv/versions/3.6.6/lib/python3.6/lib-dynload/resource.cpython-36m-x86_64-linux-gnu.so to 755
changing mode of /home/python/.pyenv/versions/3.6.6/lib/python3.6/lib-dynload/nis.cpython-36m-x86_64-linux-gnu.so to 755
changing mode of /home/python/.pyenv/versions/3.6.6/lib/python3.6/lib-dynload/_curses_panel.cpython-36m-x86_64-linux-gnu.so to 755
changing mode of /home/python/.pyenv/versions/3.6.6/lib/python3.6/lib-dynload/zlib.cpython-36m-x86_64-linux-gnu.so to 755
changing mode of /home/python/.pyenv/versions/3.6.6/lib/python3.6/lib-dynload/binascii.cpython-36m-x86_64-linux-gnu.so to 755
changing mode of /home/python/.pyenv/versions/3.6.6/lib/python3.6/lib-dynload/_curses.cpython-36m-x86_64-linux-gnu.so to 755
changing mode of /home/python/.pyenv/versions/3.6.6/lib/python3.6/lib-dynload/_bz2.cpython-36m-x86_64-linux-gnu.so to 755
changing mode of /home/python/.pyenv/versions/3.6.6/lib/python3.6/lib-dynload/_elementtree.cpython-36m-x86_64-linux-gnu.so to 755
changing mode of /home/python/.pyenv/versions/3.6.6/lib/python3.6/lib-dynload/_multibytecodec.cpython-36m-x86_64-linux-gnu.so to 755
changing mode of /home/python/.pyenv/versions/3.6.6/lib/python3.6/lib-dynload/_codecs_kr.cpython-36m-x86_64-linux-gnu.so to 755
changing mode of /home/python/.pyenv/versions/3.6.6/lib/python3.6/lib-dynload/_codecs_jp.cpython-36m-x86_64-linux-gnu.so to 755
changing mode of /home/python/.pyenv/versions/3.6.6/lib/python3.6/lib-dynload/_codecs_cn.cpython-36m-x86_64-linux-gnu.so to 755
changing mode of /home/python/.pyenv/versions/3.6.6/lib/python3.6/lib-dynload/_codecs_tw.cpython-36m-x86_64-linux-gnu.so to 755
changing mode of /home/python/.pyenv/versions/3.6.6/lib/python3.6/lib-dynload/_codecs_hk.cpython-36m-x86_64-linux-gnu.so to 755
changing mode of /home/python/.pyenv/versions/3.6.6/lib/python3.6/lib-dynload/_codecs_iso2022.cpython-36m-x86_64-linux-gnu.so to 755
changing mode of /home/python/.pyenv/versions/3.6.6/lib/python3.6/lib-dynload/pyexpat.cpython-36m-x86_64-linux-gnu.so to 755
changing mode of /home/python/.pyenv/versions/3.6.6/lib/python3.6/lib-dynload/_multiprocessing.cpython-36m-x86_64-linux-gnu.so to 755
changing mode of /home/python/.pyenv/versions/3.6.6/lib/python3.6/lib-dynload/ossaudiodev.cpython-36m-x86_64-linux-gnu.so to 755
changing mode of /home/python/.pyenv/versions/3.6.6/lib/python3.6/lib-dynload/xxlimited.cpython-36m-x86_64-linux-gnu.so to 755
changing mode of /home/python/.pyenv/versions/3.6.6/lib/python3.6/lib-dynload/_decimal.cpython-36m-x86_64-linux-gnu.so to 755
changing mode of /home/python/.pyenv/versions/3.6.6/lib/python3.6/lib-dynload/_ctypes.cpython-36m-x86_64-linux-gnu.so to 755
changing mode of /home/python/.pyenv/versions/3.6.6/lib/python3.6/lib-dynload/ to 755
changing mode of /home/python/.pyenv/versions/3.6.6/lib/python3.6/lib-dynload/__pycache__ to 755
running install_scripts
copying build/scripts-3.6/pydoc3.6 -> /home/python/.pyenv/versions/3.6.6/bin
copying build/scripts-3.6/idle3.6 -> /home/python/.pyenv/versions/3.6.6/bin
copying build/scripts-3.6/2to3-3.6 -> /home/python/.pyenv/versions/3.6.6/bin
copying build/scripts-3.6/pyvenv-3.6 -> /home/python/.pyenv/versions/3.6.6/bin
changing mode of /home/python/.pyenv/versions/3.6.6/bin/pydoc3.6 to 775
changing mode of /home/python/.pyenv/versions/3.6.6/bin/idle3.6 to 775
changing mode of /home/python/.pyenv/versions/3.6.6/bin/2to3-3.6 to 775
changing mode of /home/python/.pyenv/versions/3.6.6/bin/pyvenv-3.6 to 775
rm /home/python/.pyenv/versions/3.6.6/lib/python3.6/lib-dynload/_sysconfigdata_m_linux_x86_64-linux-gnu.py
rm -r /home/python/.pyenv/versions/3.6.6/lib/python3.6/lib-dynload/__pycache__
Creating directory /home/python/.pyenv/versions/3.6.6/share/man
Creating directory /home/python/.pyenv/versions/3.6.6/share/man/man1
/usr/bin/install -c -m 644 ./Misc/python.man \
/home/python/.pyenv/versions/3.6.6/share/man/man1/python3.6.1
if test ! -d /home/python/.pyenv/versions/3.6.6/lib/pkgconfig; then \
echo "Creating directory /home/python/.pyenv/versions/3.6.6/lib/pkgconfig"; \
/usr/bin/install -c -d -m 755 /home/python/.pyenv/versions/3.6.6/lib/pkgconfig; \
fi
if test -f /home/python/.pyenv/versions/3.6.6/bin/python3 -o -h /home/python/.pyenv/versions/3.6.6/bin/python3; \
then rm -f /home/python/.pyenv/versions/3.6.6/bin/python3; \
else true; \
fi
(cd /home/python/.pyenv/versions/3.6.6/bin; ln -s python3.6 python3)
if test "3.6" != "3.6m"; then \
rm -f /home/python/.pyenv/versions/3.6.6/bin/python3.6-config; \
(cd /home/python/.pyenv/versions/3.6.6/bin; ln -s python3.6m-config python3.6-config); \
rm -f /home/python/.pyenv/versions/3.6.6/lib/pkgconfig/python-3.6m.pc; \
(cd /home/python/.pyenv/versions/3.6.6/lib/pkgconfig; ln -s python-3.6.pc python-3.6m.pc); \
fi
rm -f /home/python/.pyenv/versions/3.6.6/bin/python3-config
(cd /home/python/.pyenv/versions/3.6.6/bin; ln -s python3.6-config python3-config)
rm -f /home/python/.pyenv/versions/3.6.6/lib/pkgconfig/python3.pc
(cd /home/python/.pyenv/versions/3.6.6/lib/pkgconfig; ln -s python-3.6.pc python3.pc)
rm -f /home/python/.pyenv/versions/3.6.6/bin/idle3
(cd /home/python/.pyenv/versions/3.6.6/bin; ln -s idle3.6 idle3)
rm -f /home/python/.pyenv/versions/3.6.6/bin/pydoc3
(cd /home/python/.pyenv/versions/3.6.6/bin; ln -s pydoc3.6 pydoc3)
rm -f /home/python/.pyenv/versions/3.6.6/bin/2to3
(cd /home/python/.pyenv/versions/3.6.6/bin; ln -s 2to3-3.6 2to3)
rm -f /home/python/.pyenv/versions/3.6.6/bin/pyvenv
(cd /home/python/.pyenv/versions/3.6.6/bin; ln -s pyvenv-3.6 pyvenv)
if test "x" != "x" ; then \
rm -f /home/python/.pyenv/versions/3.6.6/bin/python3-32; \
(cd /home/python/.pyenv/versions/3.6.6/bin; ln -s python3.6-32 python3-32) \
fi
rm -f /home/python/.pyenv/versions/3.6.6/share/man/man1/python3.1
(cd /home/python/.pyenv/versions/3.6.6/share/man/man1; ln -s python3.6.1 python3.1)
if test "xupgrade" != "xno" ; then \
case upgrade in \
upgrade) ensurepip="--upgrade" ;; \
install|*) ensurepip="" ;; \
esac; \
./python -E -m ensurepip \
$ensurepip --root=/ ; \
fi
Looking in links: /tmp/tmpmudoigcn
Collecting setuptools
Collecting pip
Installing collected packages: setuptools, pip
Successfully installed pip-10.0.1 setuptools-39.0.1
/tmp/python-build.20190510202618.18071 ~/.pyenv/cache
Installed Python-3.6.6 to /home/python/.pyenv/versions/3.6.6
~/.pyenv/cache
[python@node101.yinzhengjie.org.cn ~/.pyenv/cache]$
[python@node101.yinzhengjie.org.cn ~]$ pyenv version #当前Python环境为系统环境
system (set by /home/python/.pyenv/version)
[python@node101.yinzhengjie.org.cn ~]$
[python@node101.yinzhengjie.org.cn ~]$ pyenv versions #除了列出来当前Python环境为系统环境外,还列出来了我们刚刚安装的Python 3.6.6版本哟~
* system (set by /home/python/.pyenv/version)
3.6.6
[python@node101.yinzhengjie.org.cn ~]$
[python@node101.yinzhengjie.org.cn ~]$
六.Pyenv的基本使用
1>.使用global参数切换Python版本(执行后立刻全局生效,即当前终端和所有当前用户的终端都会生效,不推荐使用!)
[python@node101.yinzhengjie.org.cn ~]$ pyenv versions
* system (set by /home/python/.pyenv/version)
3.6.6
[python@node101.yinzhengjie.org.cn ~]$
[python@node101.yinzhengjie.org.cn ~]$ pyenv global 3.6.6
[python@node101.yinzhengjie.org.cn ~]$
[python@node101.yinzhengjie.org.cn ~]$ pyenv versions
system
* 3.6.6 (set by /home/python/.pyenv/version)
[python@node101.yinzhengjie.org.cn ~]$
[python@node101.yinzhengjie.org.cn ~]$ pyenv versions
system
* 3.6.6 (set by /home/python/.pyenv/version)
[python@node101.yinzhengjie.org.cn ~]$
[python@node101.yinzhengjie.org.cn ~]$
[python@node101.yinzhengjie.org.cn ~]$ pyenv global system
[python@node101.yinzhengjie.org.cn ~]$
[python@node101.yinzhengjie.org.cn ~]$ pyenv versions
* system (set by /home/python/.pyenv/version)
3.6.6
[python@node101.yinzhengjie.org.cn ~]$
[python@node101.yinzhengjie.org.cn ~]$
2>.使用global参数切换Python版本(执行后立刻对当前终端生效,并不影响其他终端,你可以理解为临时性的,下次连接后恢复默认配置,用处不大)
[python@node101.yinzhengjie.org.cn ~]$ pyenv version
system (set by /home/python/.python-version)
[python@node101.yinzhengjie.org.cn ~]$
[python@node101.yinzhengjie.org.cn ~]$
[python@node101.yinzhengjie.org.cn ~]$ pyenv shell 3.6.6
[python@node101.yinzhengjie.org.cn ~]$
[python@node101.yinzhengjie.org.cn ~]$ pyenv version
3.6.6 (set by PYENV_VERSION environment variable)
[python@node101.yinzhengjie.org.cn ~]$
3>.使用local参数切换Python版本(执行后立刻对当前目录及其子目录生效,强烈推荐使用,在生产环境使用它是再适合不过啦~)
[python@node101.yinzhengjie.org.cn ~]$ ll
total 0
[python@node101.yinzhengjie.org.cn ~]$
[python@node101.yinzhengjie.org.cn ~]$ mkdir devops/project -pv
mkdir: created directory ‘devops’
mkdir: created directory ‘devops/project’
[python@node101.yinzhengjie.org.cn ~]$
[python@node101.yinzhengjie.org.cn ~]$ cd devops/project/
[python@node101.yinzhengjie.org.cn ~/devops/project]$
[python@node101.yinzhengjie.org.cn ~/devops/project]$ pyenv local 3.6.6
[python@node101.yinzhengjie.org.cn ~/devops/project]$
[python@node101.yinzhengjie.org.cn ~/devops/project]$ pyenv version
3.6.6 (set by /home/python/devops/project/.python-version)
[python@node101.yinzhengjie.org.cn ~/devops/project]$
[python@node101.yinzhengjie.org.cn ~/devops/project]$ python -V
Python 3.6.6
[python@node101.yinzhengjie.org.cn ~/devops/project]$
[python@node101.yinzhengjie.org.cn ~/devops/project]$ ll
total 0
[python@node101.yinzhengjie.org.cn ~/devops/project]$
[python@node101.yinzhengjie.org.cn ~/devops/project]$ mkdir cmdb
[python@node101.yinzhengjie.org.cn ~/devops/project]$
[python@node101.yinzhengjie.org.cn ~/devops/project]$ cd cmdb/
[python@node101.yinzhengjie.org.cn ~/devops/project/cmdb]$
[python@node101.yinzhengjie.org.cn ~/devops/project/cmdb]$ python -V
Python 3.6.6
[python@node101.yinzhengjie.org.cn ~/devops/project/cmdb]$
[python@node101.yinzhengjie.org.cn ~/devops/project/cmdb]$ pyenv version
3.6.6 (set by /home/python/devops/project/.python-version)
[python@node101.yinzhengjie.org.cn ~/devops/project/cmdb]$
[python@node101.yinzhengjie.org.cn ~/devops/project/cmdb]$
4>.更新pyenv版本(更新的目的是为了获得最新Python版本支持)
[python@node101.yinzhengjie.org.cn ~]$ pyenv update
Updating /home/python/.pyenv...
From https://github.com/pyenv/pyenv
* branch master -> FETCH_HEAD
Already up-to-date.
Updating /home/python/.pyenv/plugins/pyenv-doctor...
From https://github.com/pyenv/pyenv-doctor
* branch master -> FETCH_HEAD
Already up-to-date.
Updating /home/python/.pyenv/plugins/pyenv-installer...
From https://github.com/pyenv/pyenv-installer
* branch master -> FETCH_HEAD
Already up-to-date.
Updating /home/python/.pyenv/plugins/pyenv-update...
From https://github.com/pyenv/pyenv-update
* branch master -> FETCH_HEAD
Already up-to-date.
Updating /home/python/.pyenv/plugins/pyenv-virtualenv...
From https://github.com/pyenv/pyenv-virtualenv
* branch master -> FETCH_HEAD
Already up-to-date.
Updating /home/python/.pyenv/plugins/pyenv-which-ext...
From https://github.com/pyenv/pyenv-which-ext
* branch master -> FETCH_HEAD
Already up-to-date.
[python@node101.yinzhengjie.org.cn ~]$
七.Virtualenv虚拟环境设置(主要应用于多人开发,方便实现包的管理等)
1>.为什么要使用虚拟环境
因为刚才使用的Python环境都是一个公共的空间,如果多个项目使用不同Python版本开发,或者使用不同的Python版本部署运行,或者使用同样的版本开发的但不同项目使用了不同版本的库等等。这些问题都会带来冲突,最后的解决办法就是每一个独立运行自己的“独立小环境”中。
2>. 我们使用在线方式安装一下Python 3.7.1版本(需要注意的是,Python3.7以上版本需要安装“libffi-devel”软件包)
[python@node101.yinzhengjie.org.cn ~]$ pyenv install 3.7.1 -v
/tmp/python-build.20190510214733.69816 ~
Downloading Python-3.7.1.tar.xz...
-> https://www.python.org/ftp/python/3.7.1/Python-3.7.1.tar.xz
........
changing mode of /home/python/.pyenv/versions/3.7.1/lib/python3.7/lib-dynload/_sha256.cpython-37m-x86_64-linux-gnu.so to 755
changing mode of /home/python/.pyenv/versions/3.7.1/lib/python3.7/lib-dynload/_sha512.cpython-37m-x86_64-linux-gnu.so to 755
changing mode of /home/python/.pyenv/versions/3.7.1/lib/python3.7/lib-dynload/_md5.cpython-37m-x86_64-linux-gnu.so to 755
changing mode of /home/python/.pyenv/versions/3.7.1/lib/python3.7/lib-dynload/_sha1.cpython-37m-x86_64-linux-gnu.so to 755
changing mode of /home/python/.pyenv/versions/3.7.1/lib/python3.7/lib-dynload/_blake2.cpython-37m-x86_64-linux-gnu.so to 755
changing mode of /home/python/.pyenv/versions/3.7.1/lib/python3.7/lib-dynload/_sha3.cpython-37m-x86_64-linux-gnu.so to 755
changing mode of /home/python/.pyenv/versions/3.7.1/lib/python3.7/lib-dynload/_sqlite3.cpython-37m-x86_64-linux-gnu.so to 755
changing mode of /home/python/.pyenv/versions/3.7.1/lib/python3.7/lib-dynload/_dbm.cpython-37m-x86_64-linux-gnu.so to 755
changing mode of /home/python/.pyenv/versions/3.7.1/lib/python3.7/lib-dynload/_gdbm.cpython-37m-x86_64-linux-gnu.so to 755
changing mode of /home/python/.pyenv/versions/3.7.1/lib/python3.7/lib-dynload/termios.cpython-37m-x86_64-linux-gnu.so to 755
changing mode of /home/python/.pyenv/versions/3.7.1/lib/python3.7/lib-dynload/resource.cpython-37m-x86_64-linux-gnu.so to 755
changing mode of /home/python/.pyenv/versions/3.7.1/lib/python3.7/lib-dynload/nis.cpython-37m-x86_64-linux-gnu.so to 755
changing mode of /home/python/.pyenv/versions/3.7.1/lib/python3.7/lib-dynload/_curses.cpython-37m-x86_64-linux-gnu.so to 755
changing mode of /home/python/.pyenv/versions/3.7.1/lib/python3.7/lib-dynload/_curses_panel.cpython-37m-x86_64-linux-gnu.so to 755
changing mode of /home/python/.pyenv/versions/3.7.1/lib/python3.7/lib-dynload/zlib.cpython-37m-x86_64-linux-gnu.so to 755
changing mode of /home/python/.pyenv/versions/3.7.1/lib/python3.7/lib-dynload/binascii.cpython-37m-x86_64-linux-gnu.so to 755
changing mode of /home/python/.pyenv/versions/3.7.1/lib/python3.7/lib-dynload/_bz2.cpython-37m-x86_64-linux-gnu.so to 755
changing mode of /home/python/.pyenv/versions/3.7.1/lib/python3.7/lib-dynload/pyexpat.cpython-37m-x86_64-linux-gnu.so to 755
changing mode of /home/python/.pyenv/versions/3.7.1/lib/python3.7/lib-dynload/_elementtree.cpython-37m-x86_64-linux-gnu.so to 755
changing mode of /home/python/.pyenv/versions/3.7.1/lib/python3.7/lib-dynload/_multibytecodec.cpython-37m-x86_64-linux-gnu.so to 755
changing mode of /home/python/.pyenv/versions/3.7.1/lib/python3.7/lib-dynload/_codecs_kr.cpython-37m-x86_64-linux-gnu.so to 755
changing mode of /home/python/.pyenv/versions/3.7.1/lib/python3.7/lib-dynload/_codecs_jp.cpython-37m-x86_64-linux-gnu.so to 755
changing mode of /home/python/.pyenv/versions/3.7.1/lib/python3.7/lib-dynload/_codecs_cn.cpython-37m-x86_64-linux-gnu.so to 755
changing mode of /home/python/.pyenv/versions/3.7.1/lib/python3.7/lib-dynload/_codecs_tw.cpython-37m-x86_64-linux-gnu.so to 755
changing mode of /home/python/.pyenv/versions/3.7.1/lib/python3.7/lib-dynload/_codecs_hk.cpython-37m-x86_64-linux-gnu.so to 755
changing mode of /home/python/.pyenv/versions/3.7.1/lib/python3.7/lib-dynload/_codecs_iso2022.cpython-37m-x86_64-linux-gnu.so to 755
changing mode of /home/python/.pyenv/versions/3.7.1/lib/python3.7/lib-dynload/_decimal.cpython-37m-x86_64-linux-gnu.so to 755
changing mode of /home/python/.pyenv/versions/3.7.1/lib/python3.7/lib-dynload/_multiprocessing.cpython-37m-x86_64-linux-gnu.so to 755
changing mode of /home/python/.pyenv/versions/3.7.1/lib/python3.7/lib-dynload/ossaudiodev.cpython-37m-x86_64-linux-gnu.so to 755
changing mode of /home/python/.pyenv/versions/3.7.1/lib/python3.7/lib-dynload/xxlimited.cpython-37m-x86_64-linux-gnu.so to 755
changing mode of /home/python/.pyenv/versions/3.7.1/lib/python3.7/lib-dynload/_ctypes.cpython-37m-x86_64-linux-gnu.so to 755
changing mode of /home/python/.pyenv/versions/3.7.1/lib/python3.7/lib-dynload/ to 755
changing mode of /home/python/.pyenv/versions/3.7.1/lib/python3.7/lib-dynload/__pycache__ to 755
running install_scripts
copying build/scripts-3.7/pydoc3.7 -> /home/python/.pyenv/versions/3.7.1/bin
copying build/scripts-3.7/idle3.7 -> /home/python/.pyenv/versions/3.7.1/bin
copying build/scripts-3.7/2to3-3.7 -> /home/python/.pyenv/versions/3.7.1/bin
copying build/scripts-3.7/pyvenv-3.7 -> /home/python/.pyenv/versions/3.7.1/bin
changing mode of /home/python/.pyenv/versions/3.7.1/bin/pydoc3.7 to 775
changing mode of /home/python/.pyenv/versions/3.7.1/bin/idle3.7 to 775
changing mode of /home/python/.pyenv/versions/3.7.1/bin/2to3-3.7 to 775
changing mode of /home/python/.pyenv/versions/3.7.1/bin/pyvenv-3.7 to 775
rm /home/python/.pyenv/versions/3.7.1/lib/python3.7/lib-dynload/_sysconfigdata_m_linux_x86_64-linux-gnu.py
rm -r /home/python/.pyenv/versions/3.7.1/lib/python3.7/lib-dynload/__pycache__
Creating directory /home/python/.pyenv/versions/3.7.1/share/man
Creating directory /home/python/.pyenv/versions/3.7.1/share/man/man1
/usr/bin/install -c -m 644 ./Misc/python.man \
/home/python/.pyenv/versions/3.7.1/share/man/man1/python3.7.1
if test ! -d /home/python/.pyenv/versions/3.7.1/lib/pkgconfig; then \
echo "Creating directory /home/python/.pyenv/versions/3.7.1/lib/pkgconfig"; \
/usr/bin/install -c -d -m 755 /home/python/.pyenv/versions/3.7.1/lib/pkgconfig; \
fi
if test -f /home/python/.pyenv/versions/3.7.1/bin/python3 -o -h /home/python/.pyenv/versions/3.7.1/bin/python3; \
then rm -f /home/python/.pyenv/versions/3.7.1/bin/python3; \
else true; \
fi
(cd /home/python/.pyenv/versions/3.7.1/bin; ln -s python3.7 python3)
if test "3.7" != "3.7m"; then \
rm -f /home/python/.pyenv/versions/3.7.1/bin/python3.7-config; \
(cd /home/python/.pyenv/versions/3.7.1/bin; ln -s python3.7m-config python3.7-config); \
rm -f /home/python/.pyenv/versions/3.7.1/lib/pkgconfig/python-3.7m.pc; \
(cd /home/python/.pyenv/versions/3.7.1/lib/pkgconfig; ln -s python-3.7.pc python-3.7m.pc); \
fi
rm -f /home/python/.pyenv/versions/3.7.1/bin/python3-config
(cd /home/python/.pyenv/versions/3.7.1/bin; ln -s python3.7-config python3-config)
rm -f /home/python/.pyenv/versions/3.7.1/lib/pkgconfig/python3.pc
(cd /home/python/.pyenv/versions/3.7.1/lib/pkgconfig; ln -s python-3.7.pc python3.pc)
rm -f /home/python/.pyenv/versions/3.7.1/bin/idle3
(cd /home/python/.pyenv/versions/3.7.1/bin; ln -s idle3.7 idle3)
rm -f /home/python/.pyenv/versions/3.7.1/bin/pydoc3
(cd /home/python/.pyenv/versions/3.7.1/bin; ln -s pydoc3.7 pydoc3)
rm -f /home/python/.pyenv/versions/3.7.1/bin/2to3
(cd /home/python/.pyenv/versions/3.7.1/bin; ln -s 2to3-3.7 2to3)
rm -f /home/python/.pyenv/versions/3.7.1/bin/pyvenv
(cd /home/python/.pyenv/versions/3.7.1/bin; ln -s pyvenv-3.7 pyvenv)
if test "x" != "x" ; then \
rm -f /home/python/.pyenv/versions/3.7.1/bin/python3-32; \
(cd /home/python/.pyenv/versions/3.7.1/bin; ln -s python3.7-32 python3-32) \
fi
rm -f /home/python/.pyenv/versions/3.7.1/share/man/man1/python3.1
(cd /home/python/.pyenv/versions/3.7.1/share/man/man1; ln -s python3.7.1 python3.1)
if test "xupgrade" != "xno" ; then \
case upgrade in \
upgrade) ensurepip="--upgrade" ;; \
install|*) ensurepip="" ;; \
esac; \
./python -E -m ensurepip \
$ensurepip --root=/ ; \
fi
Looking in links: /tmp/tmpjyrtfig3
Collecting setuptools
Collecting pip
Installing collected packages: setuptools, pip
Successfully installed pip-10.0.1 setuptools-39.0.1
/tmp/python-build.20190510220411.82658 ~
~
Installed Python-3.7.1 to /home/python/.pyenv/versions/3.7.1
[python@node101.yinzhengjie.org.cn ~]$
[python@node101.yinzhengjie.org.cn ~]$ pyenv versions
system
* 3.6.6 (set by PYENV_VERSION environment variable)
3.7.1
[python@node101.yinzhengjie.org.cn ~]$
[python@node101.yinzhengjie.org.cn ~]$
[python@node101.yinzhengjie.org.cn ~]$ ll ~/.pyenv/versions/ #安装好的版本软件存放在该目录下
total 0
drwxr-xr-x 6 python python 56 May 10 20:28 3.6.6
drwxr-xr-x 6 python python 56 May 10 22:06 3.7.1
[python@node101.yinzhengjie.org.cn ~]$
[python@node101.yinzhengjie.org.cn ~]$
3>.创建虚拟环境
[python@node101.yinzhengjie.org.cn ~/devops/project/cmdb]$
[python@node101.yinzhengjie.org.cn ~/devops/project/cmdb]$ ll ~/.pyenv/versions
total 0
drwxr-xr-x 6 python python 56 May 10 20:28 3.6.6
drwxr-xr-x 6 python python 56 May 10 22:06 3.7.1
[python@node101.yinzhengjie.org.cn ~/devops/project/cmdb]$
[python@node101.yinzhengjie.org.cn ~/devops/project/cmdb]$ pyenv virtualenv 3.7.1 jason371 #把3.7.1创建成虚拟环境
Looking in links: /tmp/tmpx7wtnsw2
Requirement already satisfied: setuptools in /home/python/.pyenv/versions/3.7.1/envs/jason371/lib/python3.7/site-packages (39.0.1)
Requirement already satisfied: pip in /home/python/.pyenv/versions/3.7.1/envs/jason371/lib/python3.7/site-packages (10.0.1)
[python@node101.yinzhengjie.org.cn ~/devops/project/cmdb]$
[python@node101.yinzhengjie.org.cn ~/devops/project/cmdb]$ ll ~/.pyenv/versions
total 0
drwxr-xr-x 6 python python 56 May 10 20:28 3.6.6
drwxr-xr-x 7 python python 68 May 10 22:19 3.7.1
lrwxrwxrwx 1 python python 48 May 10 22:19 jason371 -> /home/python/.pyenv/versions/3.7.1/envs/jason371 #发现没有,创建一个虚拟环境会生成一个目录哟!
[python@node101.yinzhengjie.org.cn ~/devops/project/cmdb]$
[python@node101.yinzhengjie.org.cn ~/devops/project/cmdb]$
[python@node101.yinzhengjie.org.cn ~/devops/project/cmdb]$ pyenv versions
* system (set by /home/python/devops/project/.python-version)
3.6.6
3.7.1
3.7.1/envs/jason371
jason371
[python@node101.yinzhengjie.org.cn ~/devops/project/cmdb]$
4>.使用虚拟环境
[python@node101.yinzhengjie.org.cn ~/devops/project/cmdb]$ pyenv versions
* system (set by /home/python/devops/project/.python-version)
3.6.6
3.7.1
3.7.1/envs/jason371
jason371
[python@node101.yinzhengjie.org.cn ~/devops/project/cmdb]$
[python@node101.yinzhengjie.org.cn ~/devops/project/cmdb]$ pyenv version
system (set by /home/python/devops/project/.python-version)
[python@node101.yinzhengjie.org.cn ~/devops/project/cmdb]$
[python@node101.yinzhengjie.org.cn ~/devops/project/cmdb]$ pyenv local jason371 #使用虚拟环境很简单,直接用就ok,执行后,心细的你一定发现了命令行的变化!
(jason371) [python@node101.yinzhengjie.org.cn ~/devops/project/cmdb]$
(jason371) [python@node101.yinzhengjie.org.cn ~/devops/project/cmdb]$ pyenv version
jason371 (set by /home/python/devops/project/cmdb/.python-version)
(jason371) [python@node101.yinzhengjie.org.cn ~/devops/project/cmdb]$
(jason371) [python@node101.yinzhengjie.org.cn ~/devops/project/cmdb]$
(jason371) [python@node101.yinzhengjie.org.cn ~/devops/project/cmdb]$ cd .. #注意,当我们退出当前设置虚拟环境的目录时,你就会发现目录前面命令行也发生变化啦!
[python@node101.yinzhengjie.org.cn ~/devops/project]$
[python@node101.yinzhengjie.org.cn ~/devops/project]$ pyenv version
system (set by /home/python/devops/project/.python-version)
[python@node101.yinzhengjie.org.cn ~/devops/project]$
八.Pip基本使用
1>.配置Pip的下载源为阿里云
[python@node101.yinzhengjie.org.cn ~]$ mkdir .pip
[python@node101.yinzhengjie.org.cn ~]$
[python@node101.yinzhengjie.org.cn ~]$ vi .pip/pip.conf
[python@node101.yinzhengjie.org.cn ~]$
[python@node101.yinzhengjie.org.cn ~]$
[python@node101.yinzhengjie.org.cn ~]$ cat .pip/pip.conf
[global]
index-url=https://mirrors.aliyun.com/pypi/simple/
trusted-host=mirrors.aliyun.com
[python@node101.yinzhengjie.org.cn ~]$
2>.是用pip安装Redis模块
[python@node101.yinzhengjie.org.cn ~]$ cd devops/project/cmdb/
(jason371) [python@node101.yinzhengjie.org.cn ~/devops/project/cmdb]$
(jason371) [python@node101.yinzhengjie.org.cn ~/devops/project/cmdb]$ pip install redis
Looking in indexes: https://mirrors.aliyun.com/pypi/simple/
Collecting redis
Downloading https://mirrors.aliyun.com/pypi/packages/ac/a7/cff10cc5f1180834a3ed564d148fb4329c989cbb1f2e196fc9a10fa07072/redis-3.2.1-py2.py3-none-any.whl (65kB)
|████████████████████████████████| 71kB 4.6MB/s
Installing collected packages: redis
Successfully installed redis-3.2.1
(jason371) [python@node101.yinzhengjie.org.cn ~/devops/project/cmdb]$
(jason371) [python@node101.yinzhengjie.org.cn ~/devops/project/cmdb]$ pip install reids
Looking in indexes: https://mirrors.aliyun.com/pypi/simple/
Collecting reids
Could not find a version that satisfies the requirement reids (from versions: )
No matching distribution found for reids
You are using pip version 10.0.1, however version 19.1.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
(jason371) [python@node101.yinzhengjie.org.cn ~/devops/project/cmdb]$
(jason371) [python@node101.yinzhengjie.org.cn ~/devops/project/cmdb]$ pip install --upgrade pip
Looking in indexes: https://mirrors.aliyun.com/pypi/simple/
Collecting pip
Downloading https://mirrors.aliyun.com/pypi/packages/5c/e0/be401c003291b56efc55aeba6a80ab790d3d4cece2778288d65323009420/pip-19.1.1-py2.py3-none-any.whl (1.4MB)
100% |████████████████████████████████| 1.4MB 3.0MB/s
Installing collected packages: pip
Found existing installation: pip 10.0.1
Uninstalling pip-10.0.1:
Successfully uninstalled pip-10.0.1
Successfully installed pip-19.1.1
(jason371) [python@node101.yinzhengjie.org.cn ~/devops/project/cmdb]$
[python@node101.yinzhengjie.org.cn ~]$ ll ~/.pyenv/versions/jason371/lib/python3.7/site-packages/ #在虚拟环境安装Redis成功后,我们可以查看该虚拟环境存放包的位置的确是有Redis模块的~
total 8
-rw-rw-r-- 1 python python 126 May 10 22:19 easy_install.py
drwxrwxr-x 5 python python 95 May 10 22:35 pip
drwxrwxr-x 2 python python 130 May 10 22:35 pip-19.1.1.dist-info
drwxrwxr-x 5 python python 94 May 10 22:19 pkg_resources
drwxrwxr-x 2 python python 41 May 10 22:19 __pycache__
drwxrwxr-x 3 python python 190 May 10 22:36 redis
drwxrwxr-x 2 python python 102 May 10 22:36 redis-3.2.1.dist-info
drwxrwxr-x 6 python python 4096 May 10 22:19 setuptools
drwxrwxr-x 2 python python 218 May 10 22:19 setuptools-39.0.1.dist-info
[python@node101.yinzhengjie.org.cn ~]$
[python@node101.yinzhengjie.org.cn ~]$
3>.安装ipython(它是增强的交互式Python命令行工具)
[python@node101.yinzhengjie.org.cn ~]$ cd -
/home/python/devops/project/cmdb
(jason371) [python@node101.yinzhengjie.org.cn ~/devops/project/cmdb]$
(jason371) [python@node101.yinzhengjie.org.cn ~/devops/project/cmdb]$ pip install ipython
Looking in indexes: https://mirrors.aliyun.com/pypi/simple/
Collecting ipython
Downloading https://mirrors.aliyun.com/pypi/packages/a9/2e/41dce4ed129057e05a555a7f9629aa2d5f81fdcd4d16568bc24b75a1d2c9/ipython-7.5.0-py3-none-any.whl (770kB)
|████████████████████████████████| 778kB 2.9MB/s
Collecting decorator (from ipython)
Downloading https://mirrors.aliyun.com/pypi/packages/5f/88/0075e461560a1e750a0dcbf77f1d9de775028c37a19a346a6c565a257399/decorator-4.4.0-py2.py3-none-any.whl
Collecting prompt-toolkit<2.1.0,>=2.0.0 (from ipython)
Downloading https://mirrors.aliyun.com/pypi/packages/f7/a7/9b1dd14ef45345f186ef69d175bdd2491c40ab1dfa4b2b3e4352df719ed7/prompt_toolkit-2.0.9-py3-none-any.whl (337kB)
|████████████████████████████████| 337kB 5.5MB/s
Collecting backcall (from ipython)
Downloading https://mirrors.aliyun.com/pypi/packages/1b/b3/0708228132a772de8802967af71d00c6b1f2f407e6f8efcc7055ac5900fe/backcall-0.1.0.zip
Collecting pickleshare (from ipython)
Downloading https://mirrors.aliyun.com/pypi/packages/9a/41/220f49aaea88bc6fa6cba8d05ecf24676326156c23b991e80b3f2fc24c77/pickleshare-0.7.5-py2.py3-none-any.whl
Collecting traitlets>=4.2 (from ipython)
Downloading https://mirrors.aliyun.com/pypi/packages/93/d6/abcb22de61d78e2fc3959c964628a5771e47e7cc60d53e9342e21ed6cc9a/traitlets-4.3.2-py2.py3-none-any.whl (74kB)
|████████████████████████████████| 81kB 5.3MB/s
Collecting jedi>=0.10 (from ipython)
Downloading https://mirrors.aliyun.com/pypi/packages/25/2b/1f188901be099d52d7b06f4d3b7cb9f8f09692c50697b139eaf6fa2928d8/jedi-0.13.3-py2.py3-none-any.whl (178kB)
|████████████████████████████████| 184kB 5.1MB/s
Requirement already satisfied: setuptools>=18.5 in /home/python/.pyenv/versions/3.7.1/envs/jason371/lib/python3.7/site-packages (from ipython) (39.0.1)
Collecting pexpect; sys_platform != "win32" (from ipython)
Downloading https://mirrors.aliyun.com/pypi/packages/0e/3e/377007e3f36ec42f1b84ec322ee12141a9e10d808312e5738f52f80a232c/pexpect-4.7.0-py2.py3-none-any.whl (58kB)
|████████████████████████████████| 61kB 17.8MB/s
Collecting pygments (from ipython)
Downloading https://mirrors.aliyun.com/pypi/packages/6e/00/c5cb5fc7c047da4af049005d0146b3a961b1a25d9cefbbe24bf0882a11ad/Pygments-2.4.0-py2.py3-none-any.whl (882kB)
|████████████████████████████████| 890kB 5.2MB/s
Collecting wcwidth (from prompt-toolkit<2.1.0,>=2.0.0->ipython)
Downloading https://mirrors.aliyun.com/pypi/packages/7e/9f/526a6947247599b084ee5232e4f9190a38f398d7300d866af3ab571a5bfe/wcwidth-0.1.7-py2.py3-none-any.whl
Collecting six>=1.9.0 (from prompt-toolkit<2.1.0,>=2.0.0->ipython)
Downloading https://mirrors.aliyun.com/pypi/packages/73/fb/00a976f728d0d1fecfe898238ce23f502a721c0ac0ecfedb80e0d88c64e9/six-1.12.0-py2.py3-none-any.whl
Collecting ipython-genutils (from traitlets>=4.2->ipython)
Downloading https://mirrors.aliyun.com/pypi/packages/fa/bc/9bd3b5c2b4774d5f33b2d544f1460be9df7df2fe42f352135381c347c69a/ipython_genutils-0.2.0-py2.py3-none-any.whl
Collecting parso>=0.3.0 (from jedi>=0.10->ipython)
Downloading https://mirrors.aliyun.com/pypi/packages/a7/bd/e2f4753c5fa93932899243b4299011a757ac212e9bc8ddf062f38df4e78b/parso-0.4.0-py2.py3-none-any.whl (94kB)
|████████████████████████████████| 102kB 5.4MB/s
Collecting ptyprocess>=0.5 (from pexpect; sys_platform != "win32"->ipython)
Downloading https://mirrors.aliyun.com/pypi/packages/d1/29/605c2cc68a9992d18dada28206eeada56ea4bd07a239669da41674648b6f/ptyprocess-0.6.0-py2.py3-none-any.whl
Installing collected packages: decorator, wcwidth, six, prompt-toolkit, backcall, pickleshare, ipython-genutils, traitlets, parso, jedi, ptyprocess, pexpect, pygments, ipython
Running setup.py install for backcall ... done
Successfully installed backcall-0.1.0 decorator-4.4.0 ipython-7.5.0 ipython-genutils-0.2.0 jedi-0.13.3 parso-0.4.0 pexpect-4.7.0 pickleshare-0.7.5 prompt-toolkit-2.0.9 ptyprocess-0.6.0 pygments-2.4.0 six-1.12.0 traitlets-4.3.2 wcwidth-0.1.7
(jason371) [python@node101.yinzhengjie.org.cn ~/devops/project/cmdb]$
(jason371) [python@node101.yinzhengjie.org.cn ~/devops/project/cmdb]$
(jason371) [python@node101.yinzhengjie.org.cn ~/devops/project/cmdb]$ ipython #在虚拟环境中执行ipython测试是否可用,很显然的确是好使的~
Python 3.7.1 (default, May 10 2019, 22:05:15)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.5.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: quit
(jason371) [python@node101.yinzhengjie.org.cn ~/devops/project/cmdb]$
(jason371) [python@node101.yinzhengjie.org.cn ~/devops/project/cmdb]$ cd
[python@node101.yinzhengjie.org.cn ~]$
[python@node101.yinzhengjie.org.cn ~]$ ipython #我们换个目录执行ipython时,如下所示,提示说“pyenv:ipython:command not found”.充分说明虚拟环境的特点。
pyenv: ipython: command not found
The `ipython' command exists in these Python versions:
3.7.1/envs/jason371
jason371
[python@node101.yinzhengjie.org.cn ~]$
[python@node101.yinzhengjie.org.cn ~]$
4>.导出包(虚拟环境的好处就是在于和其他项目运行环境隔离。每一个独立的环境都可以使用pip命令导出已经安装的包。方便在另外一个虚拟环境安装)
(jason371) [python@node101.yinzhengjie.org.cn ~/devops/project/cmdb]$
(jason371) [python@node101.yinzhengjie.org.cn ~/devops/project/cmdb]$ mkdir ~/package
(jason371) [python@node101.yinzhengjie.org.cn ~/devops/project/cmdb]$
(jason371) [python@node101.yinzhengjie.org.cn ~/devops/project/cmdb]$ pip freeze > ~/package/pkg-20190511
(jason371) [python@node101.yinzhengjie.org.cn ~/devops/project/cmdb]$
(jason371) [python@node101.yinzhengjie.org.cn ~/devops/project/cmdb]$ cat ~/package/pkg-20190511
attrs==19.1.0
backcall==0.1.0
bleach==3.1.0
decorator==4.4.0
defusedxml==0.6.0
entrypoints==0.3
ipykernel==5.1.0
ipython==7.5.0
ipython-genutils==0.2.0
ipywidgets==7.4.2
jedi==0.13.3
Jinja2==2.10.1
jsonschema==3.0.1
jupyter==1.0.0
jupyter-client==5.2.4
jupyter-console==6.0.0
jupyter-core==4.4.0
MarkupSafe==1.1.1
mistune==0.8.4
nbconvert==5.5.0
nbformat==4.4.0
notebook==5.7.8
pandocfilters==1.4.2
parso==0.4.0
pexpect==4.7.0
pickleshare==0.7.5
prometheus-client==0.6.0
prompt-toolkit==2.0.9
ptyprocess==0.6.0
Pygments==2.4.0
pyrsistent==0.15.1
python-dateutil==2.8.0
pyzmq==18.0.1
qtconsole==4.4.4
redis==3.2.1
Send2Trash==1.5.0
six==1.12.0
terminado==0.8.2
testpath==0.4.2
tornado==6.0.2
traitlets==4.3.2
wcwidth==0.1.7
webencodings==0.5.1
widgetsnbextension==3.4.2
(jason371) [python@node101.yinzhengjie.org.cn ~/devops/project/cmdb]$
5>.导入包
(jason371) [python@node101.yinzhengjie.org.cn ~/devops/project/cmdb]$ mkdir ~/devops/project/web
(jason371) [python@node101.yinzhengjie.org.cn ~/devops/project/cmdb]$
(jason371) [python@node101.yinzhengjie.org.cn ~/devops/project/cmdb]$ cd ~/devops/project/web/
[python@node101.yinzhengjie.org.cn ~/devops/project/web]$
[python@node101.yinzhengjie.org.cn ~/devops/project/web]$ pyenv versions
* system (set by /home/python/devops/project/.python-version)
3.6.6
3.7.1
3.7.1/envs/jason371
jason371
[python@node101.yinzhengjie.org.cn ~/devops/project/web]$
[python@node101.yinzhengjie.org.cn ~/devops/project/web]$ pyenv virtualenv 3.7.1 web371
Looking in links: /tmp/tmp335x22ar
Requirement already satisfied: setuptools in /home/python/.pyenv/versions/3.7.1/envs/web371/lib/python3.7/site-packages (39.0.1)
Requirement already satisfied: pip in /home/python/.pyenv/versions/3.7.1/envs/web371/lib/python3.7/site-packages (10.0.1)
[python@node101.yinzhengjie.org.cn ~/devops/project/web]$
[python@node101.yinzhengjie.org.cn ~/devops/project/web]$
[python@node101.yinzhengjie.org.cn ~/devops/project/web]$ pyenv versions
* system (set by /home/python/devops/project/.python-version)
3.6.6
3.7.1
3.7.1/envs/jason371
3.7.1/envs/web371
jason371
web371
[python@node101.yinzhengjie.org.cn ~/devops/project/web]$
[python@node101.yinzhengjie.org.cn ~/devops/project/web]$ pyenv local web371
(web371) [python@node101.yinzhengjie.org.cn ~/devops/project/web]$
(web371) [python@node101.yinzhengjie.org.cn ~/devops/project/web]$
(web371) [python@node101.yinzhengjie.org.cn ~/devops/project/web]$ pyenv versions
system
3.6.6
3.7.1
3.7.1/envs/jason371
3.7.1/envs/web371
jason371
* web371 (set by /home/python/devops/project/web/.python-version)
(web371) [python@node101.yinzhengjie.org.cn ~/devops/project/web]$
(web371) [python@node101.yinzhengjie.org.cn ~/devops/project/web]$
(web371) [python@node101.yinzhengjie.org.cn ~/devops/project/web]$ pip install -r ~/package/pkg-20190511
Looking in indexes: https://mirrors.aliyun.com/pypi/simple/
Collecting attrs==19.1.0 (from -r /home/python/package/pkg-20190511 (line 1))
Downloading https://mirrors.aliyun.com/pypi/packages/23/96/d828354fa2dbdf216eaa7b7de0db692f12c234f7ef888cc14980ef40d1d2/attrs-19.1.0-py2.py3-none-any.whl
Collecting backcall==0.1.0 (from -r /home/python/package/pkg-20190511 (line 2))
Downloading https://mirrors.aliyun.com/pypi/packages/1b/b3/0708228132a772de8802967af71d00c6b1f2f407e6f8efcc7055ac5900fe/backcall-0.1.0.zip
Collecting bleach==3.1.0 (from -r /home/python/package/pkg-20190511 (line 3))
Downloading https://mirrors.aliyun.com/pypi/packages/ab/05/27e1466475e816d3001efb6e0a85a819be17411420494a1e602c36f8299d/bleach-3.1.0-py2.py3-none-any.whl (157kB)
100% |████████████████████████████████| 163kB 6.0MB/s
Collecting decorator==4.4.0 (from -r /home/python/package/pkg-20190511 (line 4))
Downloading https://mirrors.aliyun.com/pypi/packages/5f/88/0075e461560a1e750a0dcbf77f1d9de775028c37a19a346a6c565a257399/decorator-4.4.0-py2.py3-none-any.whl
Collecting defusedxml==0.6.0 (from -r /home/python/package/pkg-20190511 (line 5))
Downloading https://mirrors.aliyun.com/pypi/packages/06/74/9b387472866358ebc08732de3da6dc48e44b0aacd2ddaa5cb85ab7e986a2/defusedxml-0.6.0-py2.py3-none-any.whl
Collecting entrypoints==0.3 (from -r /home/python/package/pkg-20190511 (line 6))
Downloading https://mirrors.aliyun.com/pypi/packages/ac/c6/44694103f8c221443ee6b0041f69e2740d89a25641e62fb4f2ee568f2f9c/entrypoints-0.3-py2.py3-none-any.whl
Collecting ipykernel==5.1.0 (from -r /home/python/package/pkg-20190511 (line 7))
Downloading https://mirrors.aliyun.com/pypi/packages/d8/b0/f0be5c5ab335196f5cce96e5b889a4fcf5bfe462eb0acc05cd7e2caf65eb/ipykernel-5.1.0-py3-none-any.whl (113kB)
100% |████████████████████████████████| 122kB 6.0MB/s
Collecting ipython==7.5.0 (from -r /home/python/package/pkg-20190511 (line 8))
Downloading https://mirrors.aliyun.com/pypi/packages/a9/2e/41dce4ed129057e05a555a7f9629aa2d5f81fdcd4d16568bc24b75a1d2c9/ipython-7.5.0-py3-none-any.whl (770kB)
100% |████████████████████████████████| 778kB 3.6MB/s
Collecting ipython-genutils==0.2.0 (from -r /home/python/package/pkg-20190511 (line 9))
Downloading https://mirrors.aliyun.com/pypi/packages/fa/bc/9bd3b5c2b4774d5f33b2d544f1460be9df7df2fe42f352135381c347c69a/ipython_genutils-0.2.0-py2.py3-none-any.whl
Collecting ipywidgets==7.4.2 (from -r /home/python/package/pkg-20190511 (line 10))
Downloading https://mirrors.aliyun.com/pypi/packages/30/9a/a008c7b1183fac9e52066d80a379b3c64eab535bd9d86cdc29a0b766fd82/ipywidgets-7.4.2-py2.py3-none-any.whl (111kB)
100% |████████████████████████████████| 112kB 5.8MB/s
Collecting jedi==0.13.3 (from -r /home/python/package/pkg-20190511 (line 11))
Downloading https://mirrors.aliyun.com/pypi/packages/25/2b/1f188901be099d52d7b06f4d3b7cb9f8f09692c50697b139eaf6fa2928d8/jedi-0.13.3-py2.py3-none-any.whl (178kB)
100% |████████████████████████████████| 184kB 6.3MB/s
Collecting Jinja2==2.10.1 (from -r /home/python/package/pkg-20190511 (line 12))
Downloading https://mirrors.aliyun.com/pypi/packages/1d/e7/fd8b501e7a6dfe492a433deb7b9d833d39ca74916fa8bc63dd1a4947a671/Jinja2-2.10.1-py2.py3-none-any.whl (124kB)
100% |████████████████████████████████| 133kB 3.6MB/s
Collecting jsonschema==3.0.1 (from -r /home/python/package/pkg-20190511 (line 13))
Downloading https://mirrors.aliyun.com/pypi/packages/aa/69/df679dfbdd051568b53c38ec8152a3ab6bc533434fc7ed11ab034bf5e82f/jsonschema-3.0.1-py2.py3-none-any.whl (54kB)
100% |████████████████████████████████| 61kB 17.5MB/s
Collecting jupyter==1.0.0 (from -r /home/python/package/pkg-20190511 (line 14))
Downloading https://mirrors.aliyun.com/pypi/packages/83/df/0f5dd132200728a86190397e1ea87cd76244e42d39ec5e88efd25b2abd7e/jupyter-1.0.0-py2.py3-none-any.whl
Collecting jupyter-client==5.2.4 (from -r /home/python/package/pkg-20190511 (line 15))
Downloading https://mirrors.aliyun.com/pypi/packages/3b/c3/3043fe9ffd140d03c9d091a056794ccdc427c56ec19b8eea74f9ea0a498f/jupyter_client-5.2.4-py2.py3-none-any.whl (89kB)
100% |████████████████████████████████| 92kB 5.6MB/s
Collecting jupyter-console==6.0.0 (from -r /home/python/package/pkg-20190511 (line 16))
Downloading https://mirrors.aliyun.com/pypi/packages/cb/ee/6374ae8c21b7d0847f9c3722dcdfac986b8e54fa9ad9ea66e1eb6320d2b8/jupyter_console-6.0.0-py2.py3-none-any.whl
Collecting jupyter-core==4.4.0 (from -r /home/python/package/pkg-20190511 (line 17))
Downloading https://mirrors.aliyun.com/pypi/packages/1d/44/065d2d7bae7bebc06f1dd70d23c36da8c50c0f08b4236716743d706762a8/jupyter_core-4.4.0-py2.py3-none-any.whl (126kB)
100% |████████████████████████████████| 133kB 4.1MB/s
Collecting MarkupSafe==1.1.1 (from -r /home/python/package/pkg-20190511 (line 18))
Downloading https://mirrors.aliyun.com/pypi/packages/98/7b/ff284bd8c80654e471b769062a9b43cc5d03e7a615048d96f4619df8d420/MarkupSafe-1.1.1-cp37-cp37m-manylinux1_x86_64.whl
Collecting mistune==0.8.4 (from -r /home/python/package/pkg-20190511 (line 19))
Downloading https://mirrors.aliyun.com/pypi/packages/09/ec/4b43dae793655b7d8a25f76119624350b4d65eb663459eb9603d7f1f0345/mistune-0.8.4-py2.py3-none-any.whl
Collecting nbconvert==5.5.0 (from -r /home/python/package/pkg-20190511 (line 20))
Downloading https://mirrors.aliyun.com/pypi/packages/35/e7/f46c9d65f149271e47fca6ab084ef5c6e4cb1870f4c5cce6690feac55231/nbconvert-5.5.0-py2.py3-none-any.whl (447kB)
100% |████████████████████████████████| 450kB 4.0MB/s
Collecting nbformat==4.4.0 (from -r /home/python/package/pkg-20190511 (line 21))
Downloading https://mirrors.aliyun.com/pypi/packages/da/27/9a654d2b6cc1eaa517d1c5a4405166c7f6d72f04f6e7eea41855fe808a46/nbformat-4.4.0-py2.py3-none-any.whl (155kB)
100% |████████████████████████████████| 163kB 5.2MB/s
Collecting notebook==5.7.8 (from -r /home/python/package/pkg-20190511 (line 22))
Downloading https://mirrors.aliyun.com/pypi/packages/f6/36/89ebfffc9dd8c8dbd81c1ffb53e3d4233ee666414c143959477cb07cc5f5/notebook-5.7.8-py2.py3-none-any.whl (9.0MB)
100% |████████████████████████████████| 9.0MB 4.5MB/s
Collecting pandocfilters==1.4.2 (from -r /home/python/package/pkg-20190511 (line 23))
Downloading https://mirrors.aliyun.com/pypi/packages/4c/ea/236e2584af67bb6df960832731a6e5325fd4441de001767da328c33368ce/pandocfilters-1.4.2.tar.gz
Collecting parso==0.4.0 (from -r /home/python/package/pkg-20190511 (line 24))
Downloading https://mirrors.aliyun.com/pypi/packages/a7/bd/e2f4753c5fa93932899243b4299011a757ac212e9bc8ddf062f38df4e78b/parso-0.4.0-py2.py3-none-any.whl (94kB)
100% |████████████████████████████████| 102kB 6.3MB/s
Collecting pexpect==4.7.0 (from -r /home/python/package/pkg-20190511 (line 25))
Downloading https://mirrors.aliyun.com/pypi/packages/0e/3e/377007e3f36ec42f1b84ec322ee12141a9e10d808312e5738f52f80a232c/pexpect-4.7.0-py2.py3-none-any.whl (58kB)
100% |████████████████████████████████| 61kB 5.1MB/s
Collecting pickleshare==0.7.5 (from -r /home/python/package/pkg-20190511 (line 26))
Downloading https://mirrors.aliyun.com/pypi/packages/9a/41/220f49aaea88bc6fa6cba8d05ecf24676326156c23b991e80b3f2fc24c77/pickleshare-0.7.5-py2.py3-none-any.whl
Collecting prometheus-client==0.6.0 (from -r /home/python/package/pkg-20190511 (line 27))
Downloading https://mirrors.aliyun.com/pypi/packages/4c/bd/b42db3ec90ffc6be805aad09c1cea4bb13a620d0cd4b21aaa44d13541d71/prometheus_client-0.6.0.tar.gz
Collecting prompt-toolkit==2.0.9 (from -r /home/python/package/pkg-20190511 (line 28))
Downloading https://mirrors.aliyun.com/pypi/packages/f7/a7/9b1dd14ef45345f186ef69d175bdd2491c40ab1dfa4b2b3e4352df719ed7/prompt_toolkit-2.0.9-py3-none-any.whl (337kB)
100% |████████████████████████████████| 337kB 4.0MB/s
Collecting ptyprocess==0.6.0 (from -r /home/python/package/pkg-20190511 (line 29))
Downloading https://mirrors.aliyun.com/pypi/packages/d1/29/605c2cc68a9992d18dada28206eeada56ea4bd07a239669da41674648b6f/ptyprocess-0.6.0-py2.py3-none-any.whl
Collecting Pygments==2.4.0 (from -r /home/python/package/pkg-20190511 (line 30))
Downloading https://mirrors.aliyun.com/pypi/packages/6e/00/c5cb5fc7c047da4af049005d0146b3a961b1a25d9cefbbe24bf0882a11ad/Pygments-2.4.0-py2.py3-none-any.whl (882kB)
100% |████████████████████████████████| 890kB 4.5MB/s
Collecting pyrsistent==0.15.1 (from -r /home/python/package/pkg-20190511 (line 31))
Downloading https://mirrors.aliyun.com/pypi/packages/2c/a7/8a50738eb27e204aa271abe170dec7bdbb07128ed892fb3a92f14a69bae3/pyrsistent-0.15.1.tar.gz (106kB)
100% |████████████████████████████████| 112kB 5.6MB/s
Collecting python-dateutil==2.8.0 (from -r /home/python/package/pkg-20190511 (line 32))
Downloading https://mirrors.aliyun.com/pypi/packages/41/17/c62faccbfbd163c7f57f3844689e3a78bae1f403648a6afb1d0866d87fbb/python_dateutil-2.8.0-py2.py3-none-any.whl (226kB)
100% |████████████████████████████████| 235kB 6.3MB/s
Collecting pyzmq==18.0.1 (from -r /home/python/package/pkg-20190511 (line 33))
Downloading https://mirrors.aliyun.com/pypi/packages/3c/72/1259cea3a7bc0ace82afd2244fdc448c4c2fb6b49a14e87ba832e00ee86a/pyzmq-18.0.1-cp37-cp37m-manylinux1_x86_64.whl (1.1MB)
100% |████████████████████████████████| 1.1MB 4.9MB/s
Collecting qtconsole==4.4.4 (from -r /home/python/package/pkg-20190511 (line 34))
Downloading https://mirrors.aliyun.com/pypi/packages/c7/45/1a50288305797fbca7c2039f9baefff1a9df603322874743fbb8408d8ec2/qtconsole-4.4.4-py2.py3-none-any.whl (113kB)
100% |████████████████████████████████| 122kB 4.0MB/s
Collecting redis==3.2.1 (from -r /home/python/package/pkg-20190511 (line 35))
Downloading https://mirrors.aliyun.com/pypi/packages/ac/a7/cff10cc5f1180834a3ed564d148fb4329c989cbb1f2e196fc9a10fa07072/redis-3.2.1-py2.py3-none-any.whl (65kB)
100% |████████████████████████████████| 71kB 4.9MB/s
Collecting Send2Trash==1.5.0 (from -r /home/python/package/pkg-20190511 (line 36))
Downloading https://mirrors.aliyun.com/pypi/packages/49/46/c3dc27481d1cc57b9385aff41c474ceb7714f7935b1247194adae45db714/Send2Trash-1.5.0-py3-none-any.whl
Collecting six==1.12.0 (from -r /home/python/package/pkg-20190511 (line 37))
Downloading https://mirrors.aliyun.com/pypi/packages/73/fb/00a976f728d0d1fecfe898238ce23f502a721c0ac0ecfedb80e0d88c64e9/six-1.12.0-py2.py3-none-any.whl
Collecting terminado==0.8.2 (from -r /home/python/package/pkg-20190511 (line 38))
Downloading https://mirrors.aliyun.com/pypi/packages/a7/56/80ea7fa66565fa75ae21ce0c16bc90067530e5d15e48854afcc86585a391/terminado-0.8.2-py2.py3-none-any.whl
Collecting testpath==0.4.2 (from -r /home/python/package/pkg-20190511 (line 39))
Downloading https://mirrors.aliyun.com/pypi/packages/be/a4/162f9ebb6489421fe46dcca2ae420369edfee4b563c668d93cb4605d12ba/testpath-0.4.2-py2.py3-none-any.whl (163kB)
100% |████████████████████████████████| 163kB 6.0MB/s
Collecting tornado==6.0.2 (from -r /home/python/package/pkg-20190511 (line 40))
Downloading https://mirrors.aliyun.com/pypi/packages/03/3f/5f89d99fca3c0100c8cede4f53f660b126d39e0d6a1e943e95cc3ed386fb/tornado-6.0.2.tar.gz (481kB)
100% |████████████████████████████████| 491kB 5.5MB/s
Collecting traitlets==4.3.2 (from -r /home/python/package/pkg-20190511 (line 41))
Downloading https://mirrors.aliyun.com/pypi/packages/93/d6/abcb22de61d78e2fc3959c964628a5771e47e7cc60d53e9342e21ed6cc9a/traitlets-4.3.2-py2.py3-none-any.whl (74kB)
100% |████████████████████████████████| 81kB 5.9MB/s
Collecting wcwidth==0.1.7 (from -r /home/python/package/pkg-20190511 (line 42))
Downloading https://mirrors.aliyun.com/pypi/packages/7e/9f/526a6947247599b084ee5232e4f9190a38f398d7300d866af3ab571a5bfe/wcwidth-0.1.7-py2.py3-none-any.whl
Collecting webencodings==0.5.1 (from -r /home/python/package/pkg-20190511 (line 43))
Downloading https://mirrors.aliyun.com/pypi/packages/f4/24/2a3e3df732393fed8b3ebf2ec078f05546de641fe1b667ee316ec1dcf3b7/webencodings-0.5.1-py2.py3-none-any.whl
Collecting widgetsnbextension==3.4.2 (from -r /home/python/package/pkg-20190511 (line 44))
Downloading https://mirrors.aliyun.com/pypi/packages/8a/81/35789a3952afb48238289171728072d26d6e76649ddc8b3588657a2d78c1/widgetsnbextension-3.4.2-py2.py3-none-any.whl (2.2MB)
100% |████████████████████████████████| 2.2MB 4.0MB/s
Requirement already satisfied: setuptools>=18.5 in /home/python/.pyenv/versions/3.7.1/envs/web371/lib/python3.7/site-packages (from ipython==7.5.0->-r /home/python/package/pkg-20190511 (line 8)) (39.0.1)
Installing collected packages: attrs, backcall, six, webencodings, bleach, decorator, defusedxml, entrypoints, ipython-genutils, traitlets, jupyter-core, python-dateutil, tornado, pyzmq, jupyter-client, ptyprocess, pexpect, Pygments, wcwidth, prompt-toolkit, pickleshare, parso, jedi, ipython, ipykernel, pyrsistent, jsonschema, nbformat, mistune, pandocfilters, MarkupSafe, Jinja2, testpath, nbconvert, Send2Trash, prometheus-client, terminado, notebook, widgetsnbextension, ipywidgets, jupyter-console, qtconsole, jupyter, redis
Running setup.py install for backcall ... done
Running setup.py install for tornado ... done
Running setup.py install for pyrsistent ... done
Running setup.py install for pandocfilters ... done
Running setup.py install for prometheus-client ... done
Successfully installed Jinja2-2.10.1 MarkupSafe-1.1.1 Pygments-2.4.0 Send2Trash-1.5.0 attrs-19.1.0 backcall-0.1.0 bleach-3.1.0 decorator-4.4.0 defusedxml-0.6.0 entrypoints-0.3 ipykernel-5.1.0 ipython-7.5.0 ipython-genutils-0.2.0 ipywidgets-7.4.2 jedi-0.13.3 jsonschema-3.0.1 jupyter-1.0.0 jupyter-client-5.2.4 jupyter-console-6.0.0 jupyter-core-4.4.0 mistune-0.8.4 nbconvert-5.5.0 nbformat-4.4.0 notebook-5.7.8 pandocfilters-1.4.2 parso-0.4.0 pexpect-4.7.0 pickleshare-0.7.5 prometheus-client-0.6.0 prompt-toolkit-2.0.9 ptyprocess-0.6.0 pyrsistent-0.15.1 python-dateutil-2.8.0 pyzmq-18.0.1 qtconsole-4.4.4 redis-3.2.1 six-1.12.0 terminado-0.8.2 testpath-0.4.2 tornado-6.0.2 traitlets-4.3.2 wcwidth-0.1.7 webencodings-0.5.1 widgetsnbextension-3.4.2
You are using pip version 10.0.1, however version 19.1.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
(web371) [python@node101.yinzhengjie.org.cn ~/devops/project/web]$
(web371) [python@node101.yinzhengjie.org.cn ~/devops/project/web]$ pip install --upgrade pip
Looking in indexes: https://mirrors.aliyun.com/pypi/simple/
Collecting pip
Downloading https://mirrors.aliyun.com/pypi/packages/5c/e0/be401c003291b56efc55aeba6a80ab790d3d4cece2778288d65323009420/pip-19.1.1-py2.py3-none-any.whl (1.4MB)
100% |████████████████████████████████| 1.4MB 2.8MB/s
Installing collected packages: pip
Found existing installation: pip 10.0.1
Uninstalling pip-10.0.1:
Successfully uninstalled pip-10.0.1
Successfully installed pip-19.1.1
(web371) [python@node101.yinzhengjie.org.cn ~/devops/project/web]$
(web371) [python@node101.yinzhengjie.org.cn ~/devops/project/web]$
(web371) [python@node101.yinzhengjie.org.cn ~/devops/project/web]$
(web371) [python@node101.yinzhengjie.org.cn ~/devops/project/web]$ pip install -r ~/package/pkg-20190511
Looking in indexes: https://mirrors.aliyun.com/pypi/simple/
Requirement already satisfied: attrs==19.1.0 in /home/python/.pyenv/versions/3.7.1/envs/web371/lib/python3.7/site-packages (from -r /home/python/package/pkg-20190511 (line 1)) (19.1.0)
Requirement already satisfied: backcall==0.1.0 in /home/python/.pyenv/versions/3.7.1/envs/web371/lib/python3.7/site-packages (from -r /home/python/package/pkg-20190511 (line 2)) (0.1.0)
Requirement already satisfied: bleach==3.1.0 in /home/python/.pyenv/versions/3.7.1/envs/web371/lib/python3.7/site-packages (from -r /home/python/package/pkg-20190511 (line 3)) (3.1.0)
Requirement already satisfied: decorator==4.4.0 in /home/python/.pyenv/versions/3.7.1/envs/web371/lib/python3.7/site-packages (from -r /home/python/package/pkg-20190511 (line 4)) (4.4.0)
Requirement already satisfied: defusedxml==0.6.0 in /home/python/.pyenv/versions/3.7.1/envs/web371/lib/python3.7/site-packages (from -r /home/python/package/pkg-20190511 (line 5)) (0.6.0)
Requirement already satisfied: entrypoints==0.3 in /home/python/.pyenv/versions/3.7.1/envs/web371/lib/python3.7/site-packages (from -r /home/python/package/pkg-20190511 (line 6)) (0.3)
Requirement already satisfied: ipykernel==5.1.0 in /home/python/.pyenv/versions/3.7.1/envs/web371/lib/python3.7/site-packages (from -r /home/python/package/pkg-20190511 (line 7)) (5.1.0)
Requirement already satisfied: ipython==7.5.0 in /home/python/.pyenv/versions/3.7.1/envs/web371/lib/python3.7/site-packages (from -r /home/python/package/pkg-20190511 (line 8)) (7.5.0)
Requirement already satisfied: ipython-genutils==0.2.0 in /home/python/.pyenv/versions/3.7.1/envs/web371/lib/python3.7/site-packages (from -r /home/python/package/pkg-20190511 (line 9)) (0.2.0)
Requirement already satisfied: ipywidgets==7.4.2 in /home/python/.pyenv/versions/3.7.1/envs/web371/lib/python3.7/site-packages (from -r /home/python/package/pkg-20190511 (line 10)) (7.4.2)
Requirement already satisfied: jedi==0.13.3 in /home/python/.pyenv/versions/3.7.1/envs/web371/lib/python3.7/site-packages (from -r /home/python/package/pkg-20190511 (line 11)) (0.13.3)
Requirement already satisfied: Jinja2==2.10.1 in /home/python/.pyenv/versions/3.7.1/envs/web371/lib/python3.7/site-packages (from -r /home/python/package/pkg-20190511 (line 12)) (2.10.1)
Requirement already satisfied: jsonschema==3.0.1 in /home/python/.pyenv/versions/3.7.1/envs/web371/lib/python3.7/site-packages (from -r /home/python/package/pkg-20190511 (line 13)) (3.0.1)
Requirement already satisfied: jupyter==1.0.0 in /home/python/.pyenv/versions/3.7.1/envs/web371/lib/python3.7/site-packages (from -r /home/python/package/pkg-20190511 (line 14)) (1.0.0)
Requirement already satisfied: jupyter-client==5.2.4 in /home/python/.pyenv/versions/3.7.1/envs/web371/lib/python3.7/site-packages (from -r /home/python/package/pkg-20190511 (line 15)) (5.2.4)
Requirement already satisfied: jupyter-console==6.0.0 in /home/python/.pyenv/versions/3.7.1/envs/web371/lib/python3.7/site-packages (from -r /home/python/package/pkg-20190511 (line 16)) (6.0.0)
Requirement already satisfied: jupyter-core==4.4.0 in /home/python/.pyenv/versions/3.7.1/envs/web371/lib/python3.7/site-packages (from -r /home/python/package/pkg-20190511 (line 17)) (4.4.0)
Requirement already satisfied: MarkupSafe==1.1.1 in /home/python/.pyenv/versions/3.7.1/envs/web371/lib/python3.7/site-packages (from -r /home/python/package/pkg-20190511 (line 18)) (1.1.1)
Requirement already satisfied: mistune==0.8.4 in /home/python/.pyenv/versions/3.7.1/envs/web371/lib/python3.7/site-packages (from -r /home/python/package/pkg-20190511 (line 19)) (0.8.4)
Requirement already satisfied: nbconvert==5.5.0 in /home/python/.pyenv/versions/3.7.1/envs/web371/lib/python3.7/site-packages (from -r /home/python/package/pkg-20190511 (line 20)) (5.5.0)
Requirement already satisfied: nbformat==4.4.0 in /home/python/.pyenv/versions/3.7.1/envs/web371/lib/python3.7/site-packages (from -r /home/python/package/pkg-20190511 (line 21)) (4.4.0)
Requirement already satisfied: notebook==5.7.8 in /home/python/.pyenv/versions/3.7.1/envs/web371/lib/python3.7/site-packages (from -r /home/python/package/pkg-20190511 (line 22)) (5.7.8)
Requirement already satisfied: pandocfilters==1.4.2 in /home/python/.pyenv/versions/3.7.1/envs/web371/lib/python3.7/site-packages (from -r /home/python/package/pkg-20190511 (line 23)) (1.4.2)
Requirement already satisfied: parso==0.4.0 in /home/python/.pyenv/versions/3.7.1/envs/web371/lib/python3.7/site-packages (from -r /home/python/package/pkg-20190511 (line 24)) (0.4.0)
Requirement already satisfied: pexpect==4.7.0 in /home/python/.pyenv/versions/3.7.1/envs/web371/lib/python3.7/site-packages (from -r /home/python/package/pkg-20190511 (line 25)) (4.7.0)
Requirement already satisfied: pickleshare==0.7.5 in /home/python/.pyenv/versions/3.7.1/envs/web371/lib/python3.7/site-packages (from -r /home/python/package/pkg-20190511 (line 26)) (0.7.5)
Requirement already satisfied: prometheus-client==0.6.0 in /home/python/.pyenv/versions/3.7.1/envs/web371/lib/python3.7/site-packages (from -r /home/python/package/pkg-20190511 (line 27)) (0.6.0)
Requirement already satisfied: prompt-toolkit==2.0.9 in /home/python/.pyenv/versions/3.7.1/envs/web371/lib/python3.7/site-packages (from -r /home/python/package/pkg-20190511 (line 28)) (2.0.9)
Requirement already satisfied: ptyprocess==0.6.0 in /home/python/.pyenv/versions/3.7.1/envs/web371/lib/python3.7/site-packages (from -r /home/python/package/pkg-20190511 (line 29)) (0.6.0)
Requirement already satisfied: Pygments==2.4.0 in /home/python/.pyenv/versions/3.7.1/envs/web371/lib/python3.7/site-packages (from -r /home/python/package/pkg-20190511 (line 30)) (2.4.0)
Requirement already satisfied: pyrsistent==0.15.1 in /home/python/.pyenv/versions/3.7.1/envs/web371/lib/python3.7/site-packages (from -r /home/python/package/pkg-20190511 (line 31)) (0.15.1)
Requirement already satisfied: python-dateutil==2.8.0 in /home/python/.pyenv/versions/3.7.1/envs/web371/lib/python3.7/site-packages (from -r /home/python/package/pkg-20190511 (line 32)) (2.8.0)
Requirement already satisfied: pyzmq==18.0.1 in /home/python/.pyenv/versions/3.7.1/envs/web371/lib/python3.7/site-packages (from -r /home/python/package/pkg-20190511 (line 33)) (18.0.1)
Requirement already satisfied: qtconsole==4.4.4 in /home/python/.pyenv/versions/3.7.1/envs/web371/lib/python3.7/site-packages (from -r /home/python/package/pkg-20190511 (line 34)) (4.4.4)
Requirement already satisfied: redis==3.2.1 in /home/python/.pyenv/versions/3.7.1/envs/web371/lib/python3.7/site-packages (from -r /home/python/package/pkg-20190511 (line 35)) (3.2.1)
Requirement already satisfied: Send2Trash==1.5.0 in /home/python/.pyenv/versions/3.7.1/envs/web371/lib/python3.7/site-packages (from -r /home/python/package/pkg-20190511 (line 36)) (1.5.0)
Requirement already satisfied: six==1.12.0 in /home/python/.pyenv/versions/3.7.1/envs/web371/lib/python3.7/site-packages (from -r /home/python/package/pkg-20190511 (line 37)) (1.12.0)
Requirement already satisfied: terminado==0.8.2 in /home/python/.pyenv/versions/3.7.1/envs/web371/lib/python3.7/site-packages (from -r /home/python/package/pkg-20190511 (line 38)) (0.8.2)
Requirement already satisfied: testpath==0.4.2 in /home/python/.pyenv/versions/3.7.1/envs/web371/lib/python3.7/site-packages (from -r /home/python/package/pkg-20190511 (line 39)) (0.4.2)
Requirement already satisfied: tornado==6.0.2 in /home/python/.pyenv/versions/3.7.1/envs/web371/lib/python3.7/site-packages (from -r /home/python/package/pkg-20190511 (line 40)) (6.0.2)
Requirement already satisfied: traitlets==4.3.2 in /home/python/.pyenv/versions/3.7.1/envs/web371/lib/python3.7/site-packages (from -r /home/python/package/pkg-20190511 (line 41)) (4.3.2)
Requirement already satisfied: wcwidth==0.1.7 in /home/python/.pyenv/versions/3.7.1/envs/web371/lib/python3.7/site-packages (from -r /home/python/package/pkg-20190511 (line 42)) (0.1.7)
Requirement already satisfied: webencodings==0.5.1 in /home/python/.pyenv/versions/3.7.1/envs/web371/lib/python3.7/site-packages (from -r /home/python/package/pkg-20190511 (line 43)) (0.5.1)
Requirement already satisfied: widgetsnbextension==3.4.2 in /home/python/.pyenv/versions/3.7.1/envs/web371/lib/python3.7/site-packages (from -r /home/python/package/pkg-20190511 (line 44)) (3.4.2)
Requirement already satisfied: setuptools>=18.5 in /home/python/.pyenv/versions/3.7.1/envs/web371/lib/python3.7/site-packages (from ipython==7.5.0->-r /home/python/package/pkg-20190511 (line 8)) (39.0.1)
(web371) [python@node101.yinzhengjie.org.cn ~/devops/project/web]$
九.使用jupyter开发Python程序
1>.安装jupyter(它是基于WEB的交互式笔记本,其中可用非常方便的使用Python,其实咱们直接安装Jupiter时,默认也会安装ipython的)
(jason371) [python@node101.yinzhengjie.org.cn ~/devops/project/cmdb]$ pip install jupyter
Looking in indexes: https://mirrors.aliyun.com/pypi/simple/
Collecting jupyter
Downloading https://mirrors.aliyun.com/pypi/packages/83/df/0f5dd132200728a86190397e1ea87cd76244e42d39ec5e88efd25b2abd7e/jupyter-1.0.0-py2.py3-none-any.whl
Collecting qtconsole (from jupyter)
Downloading https://mirrors.aliyun.com/pypi/packages/c7/45/1a50288305797fbca7c2039f9baefff1a9df603322874743fbb8408d8ec2/qtconsole-4.4.4-py2.py3-none-any.whl (113kB)
|████████████████████████████████| 122kB 3.9MB/s
Collecting ipywidgets (from jupyter)
Downloading https://mirrors.aliyun.com/pypi/packages/30/9a/a008c7b1183fac9e52066d80a379b3c64eab535bd9d86cdc29a0b766fd82/ipywidgets-7.4.2-py2.py3-none-any.whl (111kB)
|████████████████████████████████| 112kB 5.8MB/s
Collecting notebook (from jupyter)
Downloading https://mirrors.aliyun.com/pypi/packages/f6/36/89ebfffc9dd8c8dbd81c1ffb53e3d4233ee666414c143959477cb07cc5f5/notebook-5.7.8-py2.py3-none-any.whl (9.0MB)
|████████████████████████████████| 9.0MB 4.3MB/s
Collecting ipykernel (from jupyter)
Downloading https://mirrors.aliyun.com/pypi/packages/d8/b0/f0be5c5ab335196f5cce96e5b889a4fcf5bfe462eb0acc05cd7e2caf65eb/ipykernel-5.1.0-py3-none-any.whl (113kB)
|████████████████████████████████| 122kB 6.4MB/s
Collecting nbconvert (from jupyter)
Downloading https://mirrors.aliyun.com/pypi/packages/35/e7/f46c9d65f149271e47fca6ab084ef5c6e4cb1870f4c5cce6690feac55231/nbconvert-5.5.0-py2.py3-none-any.whl (447kB)
|████████████████████████████████| 450kB 6.2MB/s
Collecting jupyter-console (from jupyter)
Downloading https://mirrors.aliyun.com/pypi/packages/cb/ee/6374ae8c21b7d0847f9c3722dcdfac986b8e54fa9ad9ea66e1eb6320d2b8/jupyter_console-6.0.0-py2.py3-none-any.whl
Requirement already satisfied: ipython-genutils in /home/python/.pyenv/versions/3.7.1/envs/jason371/lib/python3.7/site-packages (from qtconsole->jupyter) (0.2.0)
Requirement already satisfied: traitlets in /home/python/.pyenv/versions/3.7.1/envs/jason371/lib/python3.7/site-packages (from qtconsole->jupyter) (4.3.2)
Collecting jupyter-client>=4.1 (from qtconsole->jupyter)
Downloading https://mirrors.aliyun.com/pypi/packages/3b/c3/3043fe9ffd140d03c9d091a056794ccdc427c56ec19b8eea74f9ea0a498f/jupyter_client-5.2.4-py2.py3-none-any.whl (89kB)
|████████████████████████████████| 92kB 5.9MB/s
Collecting jupyter-core (from qtconsole->jupyter)
Downloading https://mirrors.aliyun.com/pypi/packages/1d/44/065d2d7bae7bebc06f1dd70d23c36da8c50c0f08b4236716743d706762a8/jupyter_core-4.4.0-py2.py3-none-any.whl (126kB)
|████████████████████████████████| 133kB 6.1MB/s
Requirement already satisfied: pygments in /home/python/.pyenv/versions/3.7.1/envs/jason371/lib/python3.7/site-packages (from qtconsole->jupyter) (2.4.0)
Collecting nbformat>=4.2.0 (from ipywidgets->jupyter)
Downloading https://mirrors.aliyun.com/pypi/packages/da/27/9a654d2b6cc1eaa517d1c5a4405166c7f6d72f04f6e7eea41855fe808a46/nbformat-4.4.0-py2.py3-none-any.whl (155kB)
|████████████████████████████████| 163kB 6.3MB/s
Collecting widgetsnbextension~=3.4.0 (from ipywidgets->jupyter)
Downloading https://mirrors.aliyun.com/pypi/packages/8a/81/35789a3952afb48238289171728072d26d6e76649ddc8b3588657a2d78c1/widgetsnbextension-3.4.2-py2.py3-none-any.whl (2.2MB)
|████████████████████████████████| 2.2MB 5.9MB/s
Requirement already satisfied: ipython>=4.0.0; python_version >= "3.3" in /home/python/.pyenv/versions/3.7.1/envs/jason371/lib/python3.7/site-packages (from ipywidgets->jupyter) (7.5.0)
Collecting pyzmq>=17 (from notebook->jupyter)
Downloading https://mirrors.aliyun.com/pypi/packages/3c/72/1259cea3a7bc0ace82afd2244fdc448c4c2fb6b49a14e87ba832e00ee86a/pyzmq-18.0.1-cp37-cp37m-manylinux1_x86_64.whl (1.1MB)
|████████████████████████████████| 1.1MB 5.8MB/s
Collecting terminado>=0.8.1 (from notebook->jupyter)
Downloading https://mirrors.aliyun.com/pypi/packages/a7/56/80ea7fa66565fa75ae21ce0c16bc90067530e5d15e48854afcc86585a391/terminado-0.8.2-py2.py3-none-any.whl
Collecting Send2Trash (from notebook->jupyter)
Downloading https://mirrors.aliyun.com/pypi/packages/49/46/c3dc27481d1cc57b9385aff41c474ceb7714f7935b1247194adae45db714/Send2Trash-1.5.0-py3-none-any.whl
Collecting jinja2 (from notebook->jupyter)
Downloading https://mirrors.aliyun.com/pypi/packages/1d/e7/fd8b501e7a6dfe492a433deb7b9d833d39ca74916fa8bc63dd1a4947a671/Jinja2-2.10.1-py2.py3-none-any.whl (124kB)
|████████████████████████████████| 133kB 4.3MB/s
Collecting tornado<7,>=4.1 (from notebook->jupyter)
Downloading https://mirrors.aliyun.com/pypi/packages/03/3f/5f89d99fca3c0100c8cede4f53f660b126d39e0d6a1e943e95cc3ed386fb/tornado-6.0.2.tar.gz (481kB)
|████████████████████████████████| 491kB 6.0MB/s
Collecting prometheus-client (from notebook->jupyter)
Downloading https://mirrors.aliyun.com/pypi/packages/4c/bd/b42db3ec90ffc6be805aad09c1cea4bb13a620d0cd4b21aaa44d13541d71/prometheus_client-0.6.0.tar.gz
Collecting defusedxml (from nbconvert->jupyter)
Downloading https://mirrors.aliyun.com/pypi/packages/06/74/9b387472866358ebc08732de3da6dc48e44b0aacd2ddaa5cb85ab7e986a2/defusedxml-0.6.0-py2.py3-none-any.whl
Collecting mistune>=0.8.1 (from nbconvert->jupyter)
Downloading https://mirrors.aliyun.com/pypi/packages/09/ec/4b43dae793655b7d8a25f76119624350b4d65eb663459eb9603d7f1f0345/mistune-0.8.4-py2.py3-none-any.whl
Collecting bleach (from nbconvert->jupyter)
Downloading https://mirrors.aliyun.com/pypi/packages/ab/05/27e1466475e816d3001efb6e0a85a819be17411420494a1e602c36f8299d/bleach-3.1.0-py2.py3-none-any.whl (157kB)
|████████████████████████████████| 163kB 5.8MB/s
Collecting pandocfilters>=1.4.1 (from nbconvert->jupyter)
Downloading https://mirrors.aliyun.com/pypi/packages/4c/ea/236e2584af67bb6df960832731a6e5325fd4441de001767da328c33368ce/pandocfilters-1.4.2.tar.gz
Collecting testpath (from nbconvert->jupyter)
Downloading https://mirrors.aliyun.com/pypi/packages/be/a4/162f9ebb6489421fe46dcca2ae420369edfee4b563c668d93cb4605d12ba/testpath-0.4.2-py2.py3-none-any.whl (163kB)
|████████████████████████████████| 163kB 5.8MB/s
Collecting entrypoints>=0.2.2 (from nbconvert->jupyter)
Downloading https://mirrors.aliyun.com/pypi/packages/ac/c6/44694103f8c221443ee6b0041f69e2740d89a25641e62fb4f2ee568f2f9c/entrypoints-0.3-py2.py3-none-any.whl
Requirement already satisfied: prompt-toolkit<2.1.0,>=2.0.0 in /home/python/.pyenv/versions/3.7.1/envs/jason371/lib/python3.7/site-packages (from jupyter-console->jupyter) (2.0.9)
Requirement already satisfied: decorator in /home/python/.pyenv/versions/3.7.1/envs/jason371/lib/python3.7/site-packages (from traitlets->qtconsole->jupyter) (4.4.0)
Requirement already satisfied: six in /home/python/.pyenv/versions/3.7.1/envs/jason371/lib/python3.7/site-packages (from traitlets->qtconsole->jupyter) (1.12.0)
Collecting python-dateutil>=2.1 (from jupyter-client>=4.1->qtconsole->jupyter)
Downloading https://mirrors.aliyun.com/pypi/packages/41/17/c62faccbfbd163c7f57f3844689e3a78bae1f403648a6afb1d0866d87fbb/python_dateutil-2.8.0-py2.py3-none-any.whl (226kB)
|████████████████████████████████| 235kB 6.4MB/s
Collecting jsonschema!=2.5.0,>=2.4 (from nbformat>=4.2.0->ipywidgets->jupyter)
Downloading https://mirrors.aliyun.com/pypi/packages/aa/69/df679dfbdd051568b53c38ec8152a3ab6bc533434fc7ed11ab034bf5e82f/jsonschema-3.0.1-py2.py3-none-any.whl (54kB)
|████████████████████████████████| 61kB 5.9MB/s
Requirement already satisfied: backcall in /home/python/.pyenv/versions/3.7.1/envs/jason371/lib/python3.7/site-packages (from ipython>=4.0.0; python_version >= "3.3"->ipywidgets->jupyter) (0.1.0)
Requirement already satisfied: jedi>=0.10 in /home/python/.pyenv/versions/3.7.1/envs/jason371/lib/python3.7/site-packages (from ipython>=4.0.0; python_version >= "3.3"->ipywidgets->jupyter) (0.13.3)
Requirement already satisfied: pexpect; sys_platform != "win32" in /home/python/.pyenv/versions/3.7.1/envs/jason371/lib/python3.7/site-packages (from ipython>=4.0.0; python_version >= "3.3"->ipywidgets->jupyter) (4.7.0)
Requirement already satisfied: setuptools>=18.5 in /home/python/.pyenv/versions/3.7.1/envs/jason371/lib/python3.7/site-packages (from ipython>=4.0.0; python_version >= "3.3"->ipywidgets->jupyter) (39.0.1)
Requirement already satisfied: pickleshare in /home/python/.pyenv/versions/3.7.1/envs/jason371/lib/python3.7/site-packages (from ipython>=4.0.0; python_version >= "3.3"->ipywidgets->jupyter) (0.7.5)
Requirement already satisfied: ptyprocess; os_name != "nt" in /home/python/.pyenv/versions/3.7.1/envs/jason371/lib/python3.7/site-packages (from terminado>=0.8.1->notebook->jupyter) (0.6.0)
Collecting MarkupSafe>=0.23 (from jinja2->notebook->jupyter)
Downloading https://mirrors.aliyun.com/pypi/packages/98/7b/ff284bd8c80654e471b769062a9b43cc5d03e7a615048d96f4619df8d420/MarkupSafe-1.1.1-cp37-cp37m-manylinux1_x86_64.whl
Collecting webencodings (from bleach->nbconvert->jupyter)
Downloading https://mirrors.aliyun.com/pypi/packages/f4/24/2a3e3df732393fed8b3ebf2ec078f05546de641fe1b667ee316ec1dcf3b7/webencodings-0.5.1-py2.py3-none-any.whl
Requirement already satisfied: wcwidth in /home/python/.pyenv/versions/3.7.1/envs/jason371/lib/python3.7/site-packages (from prompt-toolkit<2.1.0,>=2.0.0->jupyter-console->jupyter) (0.1.7)
Collecting attrs>=17.4.0 (from jsonschema!=2.5.0,>=2.4->nbformat>=4.2.0->ipywidgets->jupyter)
Downloading https://mirrors.aliyun.com/pypi/packages/23/96/d828354fa2dbdf216eaa7b7de0db692f12c234f7ef888cc14980ef40d1d2/attrs-19.1.0-py2.py3-none-any.whl
Collecting pyrsistent>=0.14.0 (from jsonschema!=2.5.0,>=2.4->nbformat>=4.2.0->ipywidgets->jupyter)
Downloading https://mirrors.aliyun.com/pypi/packages/2c/a7/8a50738eb27e204aa271abe170dec7bdbb07128ed892fb3a92f14a69bae3/pyrsistent-0.15.1.tar.gz (106kB)
|████████████████████████████████| 112kB 6.5MB/s
Requirement already satisfied: parso>=0.3.0 in /home/python/.pyenv/versions/3.7.1/envs/jason371/lib/python3.7/site-packages (from jedi>=0.10->ipython>=4.0.0; python_version >= "3.3"->ipywidgets->jupyter) (0.4.0)
Installing collected packages: python-dateutil, tornado, jupyter-core, pyzmq, jupyter-client, ipykernel, qtconsole, attrs, pyrsistent, jsonschema, nbformat, terminado, Send2Trash, MarkupSafe, jinja2, defusedxml, mistune, webencodings, bleach, pandocfilters, testpath, entrypoints, nbconvert, prometheus-client, notebook, widgetsnbextension, ipywidgets, jupyter-console, jupyter
Running setup.py install for tornado ... done
Running setup.py install for pyrsistent ... done
Running setup.py install for pandocfilters ... done
Running setup.py install for prometheus-client ... done
Successfully installed MarkupSafe-1.1.1 Send2Trash-1.5.0 attrs-19.1.0 bleach-3.1.0 defusedxml-0.6.0 entrypoints-0.3 ipykernel-5.1.0 ipywidgets-7.4.2 jinja2-2.10.1 jsonschema-3.0.1 jupyter-1.0.0 jupyter-client-5.2.4 jupyter-console-6.0.0 jupyter-core-4.4.0 mistune-0.8.4 nbconvert-5.5.0 nbformat-4.4.0 notebook-5.7.8 pandocfilters-1.4.2 prometheus-client-0.6.0 pyrsistent-0.15.1 python-dateutil-2.8.0 pyzmq-18.0.1 qtconsole-4.4.4 terminado-0.8.2 testpath-0.4.2 tornado-6.0.2 webencodings-0.5.1 widgetsnbextension-3.4.2
(jason371) [python@node101.yinzhengjie.org.cn ~/devops/project/cmdb]$
(jason371) [python@node101.yinzhengjie.org.cn ~/devops/project/cmdb]$ jupyter notebook help
The Jupyter HTML Notebook.
This launches a Tornado based HTML Notebook Server that serves up an
HTML5/Javascript Notebook client.
Subcommands
-----------
Subcommands are launched as `jupyter-notebook cmd [args]`. For information on
using subcommand 'cmd', do: `jupyter-notebook cmd -h`.
list
List currently running notebook servers.
stop
Stop currently running notebook server for a given port
password
Set a password for the notebook server.
Options
-------
Arguments that take values are actually convenience aliases to full
Configurables, whose aliases are listed on the help line. For more information
on full configurables, see '--help-all'.
--debug
set log level to logging.DEBUG (maximize logging output)
--generate-config
generate default config file
-y
Answer yes to any questions instead of prompting.
--no-browser
Don't open the notebook in a browser after startup.
--pylab
DISABLED: use %pylab or %matplotlib in the notebook to enable matplotlib.
--no-mathjax
Disable MathJax
MathJax is the javascript library Jupyter uses to render math/LaTeX. It is
very large, so you may want to disable it if you have a slow internet
connection, or for offline use of the notebook.
When disabled, equations etc. will appear as their untransformed TeX source.
--allow-root
Allow the notebook to be run from root user.
--script
DEPRECATED, IGNORED
--no-script
DEPRECATED, IGNORED
--log-level=<Enum> (Application.log_level)
Default: 30
Choices: (0, 10, 20, 30, 40, 50, 'DEBUG', 'INFO', 'WARN', 'ERROR', 'CRITICAL')
Set the log level by value or name.
--config=<Unicode> (JupyterApp.config_file)
Default: ''
Full path of a config file.
--ip=<Unicode> (NotebookApp.ip)
Default: 'localhost'
The IP address the notebook server will listen on.
--port=<Int> (NotebookApp.port)
Default: 8888
The port the notebook server will listen on.
--port-retries=<Int> (NotebookApp.port_retries)
Default: 50
The number of additional ports to try if the specified port is not
available.
--transport=<CaselessStrEnum> (KernelManager.transport)
Default: 'tcp'
Choices: ['tcp', 'ipc']
--keyfile=<Unicode> (NotebookApp.keyfile)
Default: ''
The full path to a private key file for usage with SSL/TLS.
--certfile=<Unicode> (NotebookApp.certfile)
Default: ''
The full path to an SSL/TLS certificate file.
--client-ca=<Unicode> (NotebookApp.client_ca)
Default: ''
The full path to a certificate authority certificate for SSL/TLS client
authentication.
--notebook-dir=<Unicode> (NotebookApp.notebook_dir)
Default: ''
The directory to use for notebooks and kernels.
--browser=<Unicode> (NotebookApp.browser)
Default: ''
Specify what command to use to invoke a web browser when opening the
notebook. If not specified, the default browser will be determined by the
`webbrowser` standard library module, which allows setting of the BROWSER
environment variable to override it.
--pylab=<Unicode> (NotebookApp.pylab)
Default: 'disabled'
DISABLED: use %pylab or %matplotlib in the notebook to enable matplotlib.
To see all available configurables, use `--help-all`
Examples
--------
jupyter notebook # start the notebook
jupyter notebook --certfile=mycert.pem # use SSL/TLS certificate
jupyter notebook password # enter a password to protect the server
(jason371) [python@node101.yinzhengjie.org.cn ~/devops/project/cmdb]$
(jason371) [python@node101.yinzhengjie.org.cn ~/devops/project/cmdb]$
(jason371) [python@node101.yinzhengjie.org.cn ~/devops/project/cmdb]$ jupyter notebook password
Enter password:
Verify password:
[NotebookPasswordApp] Wrote hashed password to /home/python/.jupyter/jupyter_notebook_config.json
(jason371) [python@node101.yinzhengjie.org.cn ~/devops/project/cmdb]$
(jason371) [python@node101.yinzhengjie.org.cn ~/devops/project/cmdb]$
(jason371) [python@node101.yinzhengjie.org.cn ~/devops/project/cmdb]$ jupyter notebook --ip=0.0.0.0 --no-browser
[I 23:05:26.279 NotebookApp] Writing notebook server cookie secret to /run/user/1001/jupyter/notebook_cookie_secret
[I 23:05:27.403 NotebookApp] Serving notebooks from local directory: /home/python/devops/project/cmdb
[I 23:05:27.403 NotebookApp] The Jupyter Notebook is running at:
[I 23:05:27.403 NotebookApp] http://(node101.yinzhengjie.org.cn or 127.0.0.1):8888/
[I 23:05:27.403 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
2>.登录jupyter的web页面
3>.编辑web页面,新建一个python文件
4>.在web界面中我们可以进行编程操作(相当于在web界面中启动了一个ipython程序)
5>.在服务器端创建一个文件观察web页面的变化
(jason371) [python@node101.yinzhengjie.org.cn ~/devops/project/cmdb]$ ll
total 4
-rw-rw-r-- 1 python python 736 May 10 23:17 Untitled.ipynb
(jason371) [python@node101.yinzhengjie.org.cn ~/devops/project/cmdb]$
(jason371) [python@node101.yinzhengjie.org.cn ~/devops/project/cmdb]$ touch hello.py
(jason371) [python@node101.yinzhengjie.org.cn ~/devops/project/cmdb]$
(jason371) [python@node101.yinzhengjie.org.cn ~/devops/project/cmdb]$ ll
total 4
-rw-rw-r-- 1 python python 0 May 10 23:19 hello.py
-rw-rw-r-- 1 python python 736 May 10 23:17 Untitled.ipynb
(jason371) [python@node101.yinzhengjie.org.cn ~/devops/project/cmdb]$
博主推荐阅读:
Windows或者Mac操作系统安装Python环境:https://www.cnblogs.com/yinzhengjie/p/6229931.html。
关于pyenv工具更详细的安装文档可参考官方文档:https://github.com/pyenv/pyenv-installer。
来源:oschina
链接:https://my.oschina.net/u/4353951/blog/3592522