手机安装python3.5_Centos上安装python3.5以上版本

一、准备工作:

yum install zlib-devel

yum install openssl-devel

二、安装python3.5

wget https://www.python.org/ftp/python/3.5.3/Python-3.5.3.tgz

tar -zxvf Python-3.5.3.tgz

cd Python-3.5.3

./configure --prefix=/usr/local/python3 --enable-shared

make && make install

三、替换系统中的python

mv /usr/bin/python  python.bak

ln -s /usr/local/python3.5/bin/python3 /usr/bin/python

由于更改系统默认的python会影响yum,需修改如下两个文件:

/usr/bin/yum和/usr/libexec/urlgrabber-ext-down

1 Known problems with Fedora Linux and Python 3version: Error message:2 #yum search package

3 File "/usr/bin/yum", line 30

4 except KeyboardInterrupt, e:5 ^6 SyntaxError: invalid syntax7 Ifyou set python3 globally on your system change the yumshebang to python2:8 #vi /usr/bin/yum

9 FROM:10 #!/usr/bin/python

11 TO:12 #!/usr/bin/python2.7

13 Similarly: Error message:14 Downloading packages:15 File "/usr/libexec/urlgrabber-ext-down", line 28

16 except OSError, e:17 ^18 SyntaxError: invalid syntax19 Exiting on user cancel20 The issue is also related to Python 3 set as a default global version. To fix this error update/usr/libexec/urlgrabber-ext-down script:21 #vi /usr/libexec/urlgrabber-ext-down

22 FROM:23 #!/usr/bin/python

24 TO:25 #!/usr/bin/python2.7

四、安装setuptools

wget --no-check-certificate  https://pypi.python.org/packages/source/s/setuptools/setuptools-19.6.tar.gz#md5=c607dd118eae682c44ed146367a17e26

tar -zxvf setuptools-19.6.tar.gz

cd setuptools-19.6

python3 setup.py build

python3 setup.py install

(如有报错: RuntimeError: Compression requires the (missing) zlib module,则需要安装yum install zlib-devel,安装后要重新编译 python3.5:

make && make install)

五、安装pip

wget --no-check-certificate  https://pypi.python.org/packages/source/p/pip/pip-8.0.2.tar.gz#md5=3a73c4188f8dbad6a1e6f6d44d117eeb

tar -zxvf pip-8.0.2.tar.gz

cd pip-8.0.2

python3 setup.py build

python3 setup.py install

使用pip安装包测试:

如报错,则缺少yum install openssl-devel,安装完成后一样需要重新编译python3.5(make&&make install)

[root@localhost pip-9.0.1]#python -m pip install paramiko

pip is configured with locations that require TLS/SSL, however the ssl module inPython is not available.

Collecting paramiko

Could not fetch URL https://pypi.python.org/simple/paramiko/: There was a problem confirming the ssl certificate: Can't connect to HTTPS URL because the SSL module is not available. -skipping

Could not find a version that satisfies the requirement paramiko (from versions: )

No matching distribution foundfor paramiko

参考:

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值