# yum install openssl-devel bzip2-devel expat-devel gdbm-devel readline-devel sqlite-devel
yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel
下载python3.6编译安装
到python官网下载https://www.python.org
下载最新版源码,使用make altinstall,如果使用make install,在系统中将会有两个不同版本的Python在/usr/bin/目录中。这将会导致很多问题,而且不好处理。
# wget https://mirrors.sohu.com/python/3.6.0/Python-3.6.0.tgz
# tar -xzvf Python-3.6.0.tgz -C /tmp
# cd /tmp/Python-3.6.0/
把Python3.6安装到 /usr/local 目录
# ./configure --prefix=/usr/local
# make
# make altinstall
python3.6程序的执行文件:/usr/local/bin/python3.6
python3.6应用程序目录:/usr/local/lib/python3.6
pip3的执行文件:/usr/local/bin/pip3.6
pyenv3的执行文件:/usr/local/bin/pyenv-3.6
更改/usr/bin/python链接
# cd/usr/bin
# mv python python.backup
# ln -s /usr/local/bin/python3.6 /usr/bin/python
# ln -s /usr/local/bin/python3.6 /usr/bin/python3
更改yum脚本的python依赖
# cd /usr/bin
# ls yum*
yum yum-config-manager yum-debug-restore yum-groups-manager
yum-builddep yum-debug-dump yumdownloader
更改以上文件头为
#!/usr/bin/python 改为 #!/usr/bin/python2
修改gnome-tweak-tool配置文件
# vi /usr/bin/gnome-tweak-tool
#!/usr/bin/python 改为 #!/usr/bin/python2
修改urlgrabber配置文件
# vi /usr/libexec/urlgrabber-ext-down
#!/usr/bin/python 改为 #!/usr/bin/python2
mv /usr/bin/easy_install /usr/bin/easy_install.back
ln -s /usr/local/python/bin/easy_install /usr/bin/easy_install //替换原easy
1、安装
yum install epel-release -y #安装扩展源EPEL,否则可能会提示没有Python-pip软件包可以安装:No package python-pip available
yum install python-pip
2、修改官方源为豆瓣源
编辑配置文件, 如果没有, 新建一份:
[plain] view plain copy
1.
vi ~/.pip/pip.conf
添加内容如下:
[plain] view plain copy
1.
[global]
2.
index-url = http://pypi.douban.com/simple
3.
trusted-host = pypi.douban.com