一聚教程网:一个值得你收藏的教程网站

热门教程

python安装setuptools步骤详解

时间:2022-11-14 23:00:32 编辑:袖梨 来源:一聚教程网

Python中当需要安装第三方python包时,可能会用到easy_install命令。easy_install是由PEAK(Python Enterprise Application Kit)开发的setuptools包里带的一个命令,所以使用easy_install实际上是在调用setuptools来完成安装模块的工作。

为了方便后续安装各种第三方python包,需要先安装setuptools。

安装setuptools的话,下面一条简单的命令就可以搞定,脚本会自动为你安装适合你系统的对应版本。

代码如下 复制代码
# wget https://bootstrap.pypa.io/ez_setup.py -O - | python

大部分情况下,上面的命令都可以完成setuptools的安装,不过我在CentOS系统中安装setuptools的时候,貌似没那么顺利呢,所以我的解决办法如下:

代码如下 复制代码

# wget --no-check-certificate https://bootstrap.pypa.io/ez_setup.py -O - | python
--2014-09-18 09:27:42-- https://bootstrap.pypa.io/ez_setup.py
Resolving bootstrap.pypa.io... 103.245.222.175
Connecting to bootstrap.pypa.io|103.245.222.175|:443... connected.
WARNING: certificate common name `*.c.ssl.fastly.net' doesn't match requested host name `bootstrap.pypa.io'.
HTTP request sent, awaiting response... 200 OK
Length: 10476 (10K) [text/x-python]
Saving to: `STDOUT'

100%[======================================================================>] 10,476 --.-K/s in 0.1s

2014-09-18 09:27:43 (98.6 KB/s) - `-' saved [10476/10476]

Downloading https://pypi.python.org/packages/source/s/setuptools/setuptools-5.7.zip
Traceback (most recent call last):
File "", line 332, in
File "", line 327, in main
File "", line 287, in download_setuptools
File "", line 224, in download_file_wget
File "", line 169, in _clean_check
File "/usr/local/lib/python2.7/subprocess.py", line 511, in check_call
? raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['wget', 'https://pypi.python.org/packages/source/s/setuptools/setuptools-5.7.zip', '--quiet', '--output-document',

'/alidata/data/python/setuptools-5.7.zip']' returned non-zero exit status 1

自动安装脚本需要去下载一个文件,可是下载不下来,卡在Downloading这里了,只好改成手动方式下载了

代码如下 复制代码

# wget https://pypi.python.org/packages/source/s/setuptools/setuptools-5.7.zip --no-check-certificate
--2014-09-18 09:29:15-- https://pypi.python.org/packages/source/s/setuptools/setuptools-5.7.zip
Resolving pypi.python.org... 103.245.222.223
Connecting to pypi.python.org|103.245.222.223|:443... connected.
WARNING: certificate common name `www.python.org' doesn't match requested host name `pypi.python.org'.
HTTP request sent, awaiting response... 200 OK
Length: 1114918 (1.1M) [application/zip]
Saving to: `setuptools-5.7.zip'

100%[=========================================================================>] 1,114,918 41.3K/s in 34s

2014-09-18 09:29:49 (32.3 KB/s) - `setuptools-5.7.zip' saved [1114918/1114918]

下面把自动安装脚本也下载下来,让这个脚本替我们去安装

代码如下 复制代码

[root@AY1308142020485982a0Z python]# wget --no-check-certificate https://bootstrap.pypa.io/ez_setup.py
--2014-09-18 09:29:57-- https://bootstrap.pypa.io/ez_setup.py
Resolving bootstrap.pypa.io... 103.245.222.175
Connecting to bootstrap.pypa.io|103.245.222.175|:443... connected.
WARNING: certificate common name `*.c.ssl.fastly.net' doesn't match requested host name `bootstrap.pypa.io'.
HTTP request sent, awaiting response... 200 OK
Length: 10476 (10K) [text/x-python]
Saving to: `ez_setup.py'

100%[==============================>] 10,476

--.-K/s in 0s

2014-09-18 09:29:58 (55.8 MB/s) - `ez_setup.py' saved [10476/10476]

最后完成安装

代码如下 复制代码

# python ez_setup.py

热门栏目