博客为日常工作学习积累总结:
由于个人兴趣爱好对python有了解:
1.安装Python3:
参考博客:https://zhuanlan.zhihu.com/p/47868341
安装依赖包:
yum -y install zlib zlib-devel
yum -y install bzip2 bzip2-devel
yum -y install ncurses ncurses-devel
yum -y install readline readline-devel
yum -y install openssl openssl-devel
yum -y install openssl-static
yum -y install xz lzma xz-devel
yum -y install sqlite sqlite-devel
yum -y install gdbm gdbm-devel
yum -y install tk tk-devel
yum -y install gcc
下载安装包:wget https://www.python.org/ftp/python/3.6.5/Python-3.6.5.tgz
编译安装:tar zxf Python-3.6.5.tgz cd Python-3.6.5
安装到指定目录:./configure --with-ssl --prefix=/application/python3
返回信息:
如下提示检查通过:
If you want a release build with all optimizations active (LTO, PGO, etc),
please run ./configure --enable-optimizations
使用make进行编译:make
安装:make install
安装完成:
Collecting setuptools
Collecting pip
Installing collected packages: setuptools, pip
Successfully installed pip-9.0.1 setuptools-28.8.0
将python3作为的python命令:mv /usr/bin/python /usr/bin/python2.back
ln -s /application/python3/bin/python3 /usr/bin/python
设置pip3为全局默认pip
ln -n /application/python3/bin/pip3 /usr/bin/pip
修改yum命令依赖的Python2:
vi /usr/bin/yum
#!/usr/bin/python2
vi /usr/libexec/urlgrabber-ext-down
#! /usr/bin/python2
2.安装python虚拟环境:
pip install virtualenv
yum install python-virtualenv
当前路径:/application/movie
创建虚拟环境:python -m venv venvmovie
进入虚拟环境:source venvmovie/bin/activate
退出虚拟环境:deactivate