Python3、setuptools、Pip3安装详解

2017年08月19日 18:58:47 安静的技术控 阅读数:26002
 
 版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/a2011480169/article/details/77414500

博客核心内容:

1、Python3安装
2、setuptools安装
3、Pip3安装
  • 1
  • 2
  • 3

之所以写这篇博客,也是有很多原因了,每次安装都要从网上各种百度,网上的答案也是各种各样,于是决定好好总结一下,下面是我在安装的过程中参考的几篇博客,附上相应的链接: 
http://www.cnblogs.com/rookie404/p/6142151.html 
http://www.cnblogs.com/wenchengxiaopenyou/p/5709218.html 
https://seofangfa.com/python-note/setuptools-compression-requires-the-missing-zlib-module.html 
http://daiqingyang.blog.51cto.com/1070509/1275432/ 
好的,接下来进入文章的正题: 
linux下安装python3 
不建议卸载python2 可能会导致系统内其他软件无法使用. 
1、下载 
wget https://www.python.org/ftp/python/3.6.0/Python-3.6.0a1.tar.xz 
2、解压 
tar xvf Python-3.6.0a1.tar.xz 
3、编译安装 
进入目录Python-3.6.0a1,执行以下两个命令: 
./configure 
make && make install 
4、测试 
输入python3:

[root@iz2zea81ksgk8xh72ofrr0z tmp]# python3
Python 3.6.0a1 (default, Aug 19 2017, 14:53:46)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-11)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
  • 1
  • 2
  • 3
  • 4
  • 5

如果显示上面的内容,说明安装成功。 
部分截图: 


接下来我们来安装setuptools,到这里面遇到了开始遇到坑了。 
1、下载 
wget –no-check-certificate https://pypi.python.org/packages/source/s/setuptools/setuptools-19.6.tar.gz#md5=c607dd118eae682c44ed146367a17e26 
2、解压 
tar -zxvf setuptools-19.6.tar.gz

[root@iz2zea81ksgk8xh72ofrr0z software]# ll |grep setuptools-19.6
drwxr-xr-x 10 501 games 4096 Aug 19 17:34 setuptools-19.6
-rw-r--r-- 1 root root 641502 Jan 25 2016 setuptools-19.6.tar.gz
  • 1
  • 2
  • 3

3、进入setuptools-19.6编译安装

cd setuptools-19.6.tar.gz

python3 setup.py build

python3 setup.py install
  • 1
  • 2
  • 3
  • 4
  • 5

到这里如果你还没有报错的话,说明setuptools已经安装成功了,但是在这里我遇到了一个坑,当我执行python3 setup.py install时出现了错误,报错信息如下:

Compression requires the (missing) zlib module.
  • 1

出错原因:提示的很清楚,缺少 zlib模块导致安装失败 
处理方式: 
1、先安装缺少的模块(2行命令) 
yum install zlib 
yum install zlib-devel 
2、下载zlib成功后, cd Python-3.6.0a1的目录,重新执行下面的这个命令:

make && make install
  • 1

3、重新进入setuptools-19.6目录,再次执行下面的命令:

python3 setup.py install
  • 1

到这里问题解决,setuptools-19.6安装成功.


接下来我们安装Pip3 
1、下载 
wget –no-check-certificate https://pypi.python.org/packages/source/p/pip/pip-8.0.2.tar.gz#md5=3a73c4188f8dbad6a1e6f6d44d117eeb 
2、解压 
tar -zxvf pip-8.0.2.tar.gz

[root@iz2zea81ksgk8xh72ofrr0z software]# ll |grep pip
drwxr-xr-x 7 501 games 4096 Aug 19 17:44 pip-8.0.2
-rw-r--r-- 1 root root 1130183 Aug 19 17:40 pip-8.0.2.tar.gz
  • 1
  • 2
  • 3

3、进入pip-8.0.2目录,编译安装:

cd pip-8.0.2

python3 setup.py build

python3 setup.py install
  • 1
  • 2
  • 3
  • 4
  • 5

到这里pip3就安装成功了,可以检查一下:

[root@iz2zea81ksgk8xh72ofrr0z software]# whereis pip3
pip3: /usr/local/bin/pip3 /usr/local/bin/pip3.6
  • 1
  • 2

我当时到这里以为安装成功了,但是当执行pip3的时候,报错了,信息如下:

cannot import name HTTPSHandler.
  • 1

问题:提示的很清楚,缺少 HTTPSHandler模块导致安装失败 
处理方式: 
1、先安装缺少的模块(2行命令)

yum install openssl
yum install openssl-devel
  • 1
  • 2

2、下载 HTTPSHandler成功后, cd Python-3.6.0a1的目录,重新执行下面的这个命令:

make && make install
  • 1

当我执行完上一行命令之后,出现了下面的日志(部分)

Ignoring indexes: https://pypi.python.org/simple
Collecting setuptools
Collecting pip
Installing collected packages: setuptools, pip
Found existing installation: setuptools 19.6
Uninstalling setuptools-19.6:
Successfully uninstalled setuptools-19.6
Found existing installation: pip 8.0.2
Uninstalling pip-8.0.2:
Successfully uninstalled pip-8.0.2
Successfully installed pip setuptools
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11

从最后一行Successfully installed pip setuptools可以看出,我的setuptools和pip随之跟着也成功了,验证一下:

[root@iz2zea81ksgk8xh72ofrr0z software]# pip3

Usage:
pip <command> [options] Commands:
install Install packages.
download Download packages.
uninstall Uninstall packages.
freeze Output installed packages in requirements format.
list List installed packages.
show Show information about installed packages.
search Search PyPI for packages.
wheel Build wheels from your requirements.
hash Compute hashes of package archives.
completion A helper command used for command completion
help Show help for commands. General Options:
-h, --help Show help.
--isolated Run pip in an isolated mode, ignoring environment variables and user configuration.
-v, --verbose Give more output. Option is additive, and can be used up to 3 times.
-V, --version Show version and exit.
-q, --quiet Give less output.
--log <path> Path to a verbose appending log.
--proxy <proxy> Specify a proxy in the form [user:passwd@]proxy.server:port.
--retries <retries> Maximum number of retries each connection should attempt (default 5 times).
--timeout <sec> Set the socket timeout (default 15 seconds).
--exists-action <action> Default action when a path already exists: (s)witch, (i)gnore, (w)ipe, (b)ackup.
--trusted-host <hostname> Mark this host as trusted, even though it does not have valid or any HTTPS.
--cert <path> Path to alternate CA bundle.
--client-cert <path> Path to SSL client certificate, a single file containing the private key and the
certificate in PEM format.
--cache-dir <dir> Store the cache data in <dir>.
--no-cache-dir Disable the cache.
--disable-pip-version-check
Don't periodically check PyPI to determine whether a new version of pip is available for
download. Implied with --no-index.
 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38

OK,大功告成! 
总结一下注意的点,每次安装完缺少的模块之后,都需要:cd Python-3.6.0a1的目录,重新执行下面的这个命令:

make && make install

Python3、setuptools、Pip3安装详解的更多相关文章

  1. Win10 TensorFlow(gpu)安装详解

    Win10 TensorFlow(gpu)安装详解 写在前面:TensorFlow是谷歌基于DistBelief进行研发的第二代人工智能学习系统,其命名来源于本身的运行原理.Tensor(张量)意味着 ...

  2. (转)Win10 TensorFlow(gpu)安装详解

    Win10 TensorFlow(gpu)安装详解 写在前面:TensorFlow是谷歌基于DistBelief进行研发的第二代人工智能学习系统,其命名来源于本身的运行原理.Tensor(张量)意味着 ...

  3. Linux ssh登录和软件安装详解

    阿哲Style   Linux第一天 ssh登录和软件安装详解 Linux学习第一天 操作环境: Ubuntu 16.04 Win10系统,使用putty_V0.63 本身学习Linux就是想在服务器 ...

  4. 【转】Linux下Android ADB驱动安装详解

    原文网址:http://blog.csdn.net/zhenwenxian/article/details/5901350 Linux下Android ADB驱动安装详解 概述 最近由于内置的合作商比 ...

  5. scribefire 多博客管理利器 安装详解

    scribefire 多博客管理利器 安装详解 一.ScribeFire介绍 ScribeFire 是 Firefox (火狐浏览器)上著名的博客写作工具,目前已跨平台支持多浏览器(Firefox,C ...

  6. CentOS 6.5的安装详解

    CentOS 6.5的安装详解 主流: 目前的Linux操作系统主要应用于生产环境, 主流企业级Linux系统仍旧是RedHat或者CentOS 免费: RedHat 和CentOS差别不大,Cent ...

  7. Linux下tomcat的安装详解

    Linux下tomcat的安装详解 来源: ChinaUnix博客 日期: 2007.01.21 22:59 (共有0条评论) 我要评论 一,安装前的准备:1,Linux版本:我的是企业版.(至于红帽 ...

  8. Phoenix和SQuirrel安装详解

    Phoenix安装详解 描述 现有hbase的查询工具有很多如:Hive,Tez,Impala,Shark/Spark,Phoenix等.今天的主角是Phoenix. phoenix,中文译为“凤凰” ...

  9. zabbix agent安装详解

    安装 Installing repository configuration package Zabbix 2.2 for RHEL5, Oracle Linux 5, CentOS 5: rpm - ...

随机推荐

  1. 阅读《Windows 黑客编程技术详解》(甘迪文著)【正在进行】

    内容提要: 本书介绍的是黑客编程的基础技术,涉及用户层下的Windows编程和内核层下的Rootkit编程. 全书大纲: 第一篇 用户篇 平常计算机上使用的应用程序,都运行在用户层上,属于用户程序.在 ...

  2. Nvm安装步骤

    下载地址 https://github.com/coreybutler/nvm-windows/releases 解压压缩包,后是一个.exe结尾的安装文件,双击安装, 选择安装位置,如下图: 设置n ...

  3. PostGIS mysql_fdw安装(Linux)

    ##本人在安装过程中,可能因为系统环境因素或是其他原因,参考网上的文章没有一篇是非常顺利的,所以自己总结一下. ##安装过程中非常坎坷,有些地方反复了好几次,弄的有点模糊,但模糊的地方在文中我会指出. ...

  4. PostGIS 安装教程(Linux)(二)

    ##接上篇,上篇讲述了Postgresql的安装,此篇介绍postgis的安装 ##附上上篇链接:https://www.cnblogs.com/giser-s/p/11195419.html 二.安 ...

  5. UDP 协议的那点事儿

    最近在回顾计算机网络的知识,以前上课没有认真学,只记得几个高大上的术语,所以趁着这次回顾,把学到的知识用博客的形式记录下来,一来加深自己的印象,二来希望让你对这些基础知识有一个更深入的了解.当然,我会 ...

  6. Dart Learn Notes 03

    操作符 dart 有一套自己定义的操作符: 这里我就不再写了,直接copy一份官网的. 如果有过编程基础,上边展示的操作符应该都不陌生. 算术运算符 加: + 减: - 乘: * 除: / 取余: % ...

  7. linux ftp配置及实操

    一.基础知识: 1.ftp:file transfer protocal 及文件传输协,工作与应用层. 2.ftp协议的实现: 服务器端实现软件:vsftpd,pureftpd,filezilla s ...

  8. HTML5的一些验证挺方便的

    一些基本的验证都可以很简单的实现,节省了很多繁琐的步骤.

  9. 程序员的算法课(11)-KMP算法

    版权声明:本文为博主原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明. 本文链接:https://blog.csdn.net/m0_37609579/article/de ...

  10. Java工作流引擎-中间件模式代码集成

    关键词:工作流快速开发平台  工作流流设计  业务流程管理   asp.net 开源工作流  bpm工作流系统  java工作流主流框架  自定义工作流引擎 表单设计器  流程设计器 前端代码集成步骤 ...