Linux_Python2_Python3 并存安装笔记

环境: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)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值