时间 : 201708 、 环境: Ubuntu 14.04
套件: pycurl、python-setuptools(easy_install)
问题说明:
因为程式上的需求,需要安装pycurl套件在系统当中,
想透过pip去进行简易安装的时候,发现跳出错误,造成安装失败。
处理方式:
(1) 进行apt update
#apt-get update
(2) 检查curl-config是否已经安装
Ubuntu 14.04 状态下是没有安装的。
Ubuntu 16.04 已经安装完成。
用 whereis 来检查安装状况。
#whereis curl-config
如果有装安装,就会向下面一样显示路径。
ryu@ubuntu:~$ whereis curl-config
curl-config: /usr/bin/curl-config /usr/bin/X11/curl-config /usr/share/man/man1/curl-config.1.gz
如果没安装,只会有名称,但没有路径
ryu@ubuntu:~$ whereis curl-config
curl-config:
那我们这边简单试一下,curl-config会需要那些套件。
ryu@ubuntu:~$ curl-config
The program 'curl-config' can be found in the following packages:
Try: sudo apt-get install
提示讯息都那么清楚了,那我们就遵照他的步骤来进行吧。
#sudo apt-get install libcurl4-gnutls-dev
#sudo apt-get install libcurl4-nss-dev
#sudo apt-get install libcurl4-openssl-dev
安装完这三个套件,curl-config就算正式安装完毕。
(3) 来準备我们的安装工具(easy-tool)跟他的lib
#sudo apt-get install python-setuptools
#sudo apt-get install libxtst-dev
当这边安装完成,我们就可以用easy_install 指令去安装套件了。
这边我们要安装的是 pycurl
#sudo easy_install pycurl
#!#############################################
ryu@ubuntu:~$ sudo easy_install pycurl
Searching for pycurl
Reading https://pypi.python.org/simple/pycurl/
Downloading https://pypi.python.org/packages/12/3f/557356b60d8e59a1cce62ffc07ecc03e4f8a202c86adae34d895826281fb/pycurl-7.43.0.tar.gz#md5=c94bdba01da6004fa38325e9bd6b9760
Best match: pycurl 7.43.0
Processing pycurl-7.43.0.tar.gz
Writing /tmp/easy_install-G0C_V_/pycurl-7.43.0/setup.cfg
Running pycurl-7.43.0/setup.py -q bdist_egg --dist-dir /tmp/easy_install-G0C_V_/pycurl-7.43.0/egg-dist-tmp-Vfnu3d
Using curl-config (libcurl 7.35.0)
warning: no files found matching 'src/Makefile'
zip_safe flag not set; analyzing archive contents...
Moving pycurl-7.43.0-py2.7-linux-x86_64.egg to /usr/local/lib/python2.7/dist-packages
Adding pycurl 7.43.0 to easy-install.pth file
Installed /usr/local/lib/python2.7/dist-packages/pycurl-7.43.0-py2.7-linux-x86_64.egg
Processing dependencies for pycurl
Finished processing dependencies for pycurl
#!###############################################
有看到安装成功是非常开心的。
但安装成功不代表可以使用,我们还是要来测试一下。
如果安装错误讯息:
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
如果出现问题且gcc已经安装完成了,
那我们注意一下python-dev有没有正确安装
#sudo apt-get install python-dev
基本上这边安装好后,重新测试一次安装pycurl就会成功了。
测试阶段:
安装后要进行pycurl有没有安装成功,
最简单的方法就是进入python的环境下测试
这边import pycurl 没有出现其他错误提示讯息,就表示成功了。
ryu@ubuntu:~$ python
Python 2.7.6 (default, Oct 26 2016, 20:30:19)
[GCC 4.8.4] on linux2
Type "help", "copyright", "credits" or "license" for more information.
#import pycurl
#quit()
后记:
就以这次安装问题来说,原本我是打算用最简单的方式来安装pycurl
也就是使用pip,但使用pip安装时跳出了下面的问题。
#sudo pip install pycurl
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-HtcwQj/pycurl/
上网查发现,很多人都说跟相依性套件有关係。
但绝大多数人都在说CentOS上使用pip安装错误该安装甚么套件。
这部分已经有很多人介绍,所以就不多说。
反倒是没有很多说ubuntu该怎么办的。
所以我的ubuntu环境就改用easy_install的方法去进行安装。
而在CentOS下要使用easy_install的话,只要安装下面的套件就可以执行了
#yum -y install libcurl-devel
#easy_install pycurl
(全篇完)
参考网址:
http://mycodetub.logdown.com/posts/745281-install-ubuntu-1604-pycurl
文章引用自我的BLOG:
http://it001.pixnet.net/blog/post/325851562-it%e4%ba%8b%e4%bb%b6%e7%b0%bf-pycurl%e7%84%a1%e6%b3%95%e6%ad%a3%e7%a2%ba%e4%bd%bf%e7%94%a8pip%e5%ae%89%e8%a3%9d%e6%80%8e%e9%ba%bc%e8%be%a6%3f%28ubun