环境:Vmware Workstation 10,CentOS-7-x86_64-DVD-1511.iso,Xshell 4.0,ip:192.168.216.140.
[root@localhost ~]# wget https://www.python.org/ftp/python/3.6.3/Python-3.6.3.tgz
[root@localhost ~]# tar -zxvf Python-3.6.3.tgz -C /usr/local/
[root@localhost ~]# mv /usr/local/Python-3.6.3/ /usr/local/python3
[root@localhost ~]# cd /usr/local/python3/
[root@topscience python3]# yum list gcc zlib zlib-devel
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Installed Packages
gcc.x86_64 4.8.5-16.el7 @base
zlib.x86_64 1.2.7-17.el7 @anaconda
zlib-devel.x86_64 1.2.7-17.el7 @base
–with-ssl确保pip3可以使用
[root@localhost python3]# ./configure –with-ssl
[root@localhost python3]# make && make install
Installing collected packages: setuptools, pip
Successfully installed pip-9.0.1 setuptools-28.8.0
[root@localhost python3]# which python
/usr/bin/python
[root@localhost python3]# python
Python 2.7.5 (default, Nov 6 2016, 00:28:07)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-11)] on linux2
[root@localhost python3]# which python3
/usr/local/bin/python3
[root@localhost python3]# python3
Python 3.6.3 (default, Dec 4 2017, 16:38:50)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-16)] on linux
Python脚本
#!/usr/local/bin/python3
# -*- coding:utf-8 -*-
import os
os.system("echo 'hello world'")
print(os.popen("echo '你好'").read().strip())
使用pip3安装scrapy时,需要安装最新的Twisted
[root@localhost ~]# wget https://files.pythonhosted.org/packages/a2/37/298f9547606c45d75aa9792369302cc63aa4bbcf7b5f607560180dd099d2/Twisted-17.9.0.tar.bz2
[root@localhost ~]# tar -jxvf Twisted-17.9.0.tar.bz2 -C /usr/local/
[root@localhost ~]# cd /usr/local/Twisted-17.9.0/
[root@localhost Twisted-17.9.0]# python3 setup.py install
[root@localhost Twisted-17.9.0]# pip3 list
Twisted (17.9.0)
wheel (0.30.0)