关于我们

质量为本、客户为根、勇于拼搏、务实创新

< 返回新闻公共列表

服务器:Linux/ubuntu 下安装pyspider的过程

发布时间:2020-04-08 12:42:53

服务器:首先执行


pip install pyspider


此时系统提示


<span style="font-size: 16px;">Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-Lau0Qp/pycurl/ 

You are using pip version 9.0.1, however version 9.0.3 is available. 

You should consider upgrading via the 'pip install --upgrade pip' command. 

</span> 


这是pip版本的问题,执行


<span style="font-size: 16px;">sudo python -m pip install --upgrade pip</span>

升级pip


继续执行


<span style="font-size: 16px;"> sudo pip install pyspider</span>

来安装pyspider,此时报错:


<span style="font-size: 16px;">Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-szUHrj/pycurl/

</span>

原因是pyspider的依赖库未安装,需要执行


<span style="font-size: 16px;">sudo apt-get install python python-dev python-distribute python-pip libcurl4-openssl-dev libxml2-dev libxslt1-dev python-lxml</span>

命令来安装以下支持类库


本来以为可以正常安装pyspider了,可继续执行 sudo pip install pyspider时系统报错信息为:


compilation terminated. 

   error: command 'x86_64-linux-gnu-gcc' failed with exit status 1    

   ---------------------------------------- 

span style="color: rgb(255, 0, 0);">Command "/usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-B8gZjb/pycurl/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-aDBSCP-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-B8gZjb/pycurl/</span> 


原因是因为安装工具包时需要抓取网页因而要处理 https,而处理 https 又依赖加解密算法(即 cryptography 包),而 cryptography 又依赖傅立叶变换的算法以及相应的编译环境。Ubuntu 16.04 默认没有安装 libffi-dev 和 libssl-dev,gcc 也不一定安装,而目标安装包又没有将相关软件包记到依赖列表里,因此需要先手动安装:


sudo apt-get install libssl-dev libffi-dev build-essential

此时再执行 sudo pip install pyspider 就OK了!


因此Linux下安装要执行以下几个命令,(划重点!)


sudo python -m pip install --upgrade pip 

sudo apt-get install python python-dev python-distribute python-pip libcurl4-openssl-dev libxml2-dev libxslt1-dev python-lxml 

sudo apt-get install libssl-dev libffi-dev build-essential 

sudo pip install pyspider

补充:




/template/Home/Zkeys2/PC/Static