Centos上安装python3.5以上版本

h3 { color: #fff; background-color: #f7af0d; padding: 3px; margin: 10px 0px }

一、准备工作:

  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 3 version: Error message:
 2 # yum search package
 3   File "/usr/bin/yum", line 30
 4     except KeyboardInterrupt, e:
 5                             ^
 6 SyntaxError: invalid syntax
 7 If you 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 syntax
19 Exiting on user cancel
20 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)

[[email protected] pip-9.0.1]# python -m pip install paramiko
pip is configured with locations that require TLS/SSL, however the ssl module in Python 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 found for paramiko

  

  参考:

    http://www.tuicool.com/articles/j2ueiir

    http://www.cnblogs.com/Yemilice/p/6217250.html

时间: 2024-10-27 04:52:50

Centos上安装python3.5以上版本的相关文章

在centos 上安装python3.4,进入交互模式中退格键,方向键乱码问题

首先安装python3.4 下载 wget -c https://www.python.org/ftp/python/3.4.3/Python-3.4.3.tgz 解压 tar zxvf Python-3.4.3.tgz cd Python-3.4.3 ./configure --prefix=/opt/python    #因为centos自带python,为了不影响原有系统,我这里是另外安装到新目录 make install  进行安装 ln -s /opt/python/bin/pytho

centos上安装python3.6

安装python3.6可能使用的依赖 # yum install openssl-devel bzip2-devel expat-devel gdbm-devel readline-devel sqlite-devel 下载python3.6编译安装 新安装的最新centos7最小化安装没有安装wget,所以要安装一下 # yum install wget # wgethttps://www.python.org/ftp/python/3.6.0/Python-3.6.0.tgz # tar -

centos上安装Python3.4——源码安装

1.安装Python的依赖包 yum groupinstall "Development tools" yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel 2.下载Python3.4的源码包并编译 wget https://www.python.org/

centos上安装 Python3x

centos上安装 Python3.xx 下载源码包 wget wget https://www.python.org/ftp/python/3.6.1/Python-3.6.1.tar.gz 2. 安装依赖 yum install -y openssl-devel bzip2-devel expat-devel gdbm-devel readline-devel sqlite-devel 3. 安装 tar zxf Python-3.6.1.tar.gz cd Python-3.6.1 ./c

在CentOS 7上安装Python3

在CentOS 7上安装Python3 源码包安装 Python官方没有对Linux打包, 需要下载源码包进行编译. 可以自己下载最新版本的Python, 在Python下载页面, 点击Python3.x.x版本对应的Download, 在新页面的Files下, 选择Source release, 选择Gzipped source tarball或者XZ compressed source tarball压缩方式的包, 我选择的是tgz压缩. Python3.6.5 下载源码包 wget htt

关于在centos下安装python3.7.0以上版本时报错ModuleNotFoundError: No module named '_ctypes'的解决办法

3.7版本需要一个新的包libffi-devel,安装此包之后再次进行编译安装即可. #yum install libffi-devel -y#make install若在安装前移除了/usr/bin下python的文件链接依赖,此时yum无法正常使用,需要自己下载相关软件包安装,为节省读者时间,放上链接 #wget http://mirror.centos.org/centos/7/os/x86_64/Packages/libffi-devel-3.0.13-18.el7.x86_64.rpm

Centos7上安装python3.7

Centos7安装python3.7 由于python2和python3在很大程度上有些不同,因为需要,就以决定安装python3.x的版本,但由于Centos上自安装的就是pyhton2.6.所以在安装python3.7的时候,最好不要将原有的python删除,否则可能导致yum不可用.请根据个人实际情况来进行安装. 下面是安装中的具体步骤,以及遇到的一些问题,可供大家参考. 1.获取python3.7源码包 # mkdir /usr/local/python3.7 # cd /usr/loc

mac上安装python3 和 sqlite的问题

建议mac上安装python3不要使用源码自己编译安装,而要使用 brew install python3 来安装 另外安装完之后创建需环境的话,要指定新的python环境,如下: virtualenv  -p /usr/local/Cellar/python3/3.6.2/bin/python3  --no-site-packages obpy17 Mac OSX 正确地同时安装Python 2.7 和Python3 Mac OSX 正确地同时安装Python 2.7 和Python3(这个是

什么是EPEL 及 Centos上安装EPEL

RHEL以及他的衍生发行版如CentOS.Scientific Linux为了稳定,官方的rpm repository提供的rpm包往往是很滞后的,当然了,这样做这是无可厚非的,毕竟这是服务器版本,安全稳定是重点,官方的rpm repository提供的rpm包也不够丰富,很多时候需要自己编译那太辛苦了,而EPEL恰恰可以解决这两方面的问题. 什么是EPEL? EPEL的全称叫 Extra Packages for Enterprise Linux .EPEL是由 Fedora 社区打造,为 R