python install scrapy-失败,错误代码为1

时间:2018-10-21 13:15:04

标签: python scrapy lxml

我尝试通过“ pip install scrapy”安装scrapy,我得到了:

c:\python36\python.exe -u -c "import setuptools, 
tokenize;__file__='C:\\Users\\tzvia\\AppData\\Local\\Temp\\pip-install- 
07h63108\\Twisted\\setup.py';f=getattr(tokenize, 'open', open) 
(__file__);code=f.read().replace('\r\n', 
'\n');f.close();exec(compile(code, __file__, 'exec'))" install --record 
C:\Users\tzvia\AppData\Local\Temp\pip-record-hy8qkma1\install-record.txt 
--single-version-externally-managed --compile" failed with error code 1 
in C:\Users\tzvia\AppData\Local\Temp\pip-install-07h63108\Twisted\

我尝试了“ conda install -c conda-forge scrapy”,似乎scrapy已安装:

C:\Users\tzvia>conda install -c conda-forge scrapy
Solving environment: done

# All requested packages already installed.

所以我尝试使用scrapy并出错:

C:\Users\tzvia>scrapy
Traceback (most recent call last):
File "C:\Users\tzvia\Anaconda3\Scripts\scrapy-script.py", line 6, in 
<module>
from scrapy.cmdline import execute
File "C:\Users\tzvia\Anaconda3\lib\site-packages\scrapy\__init__.py", line 
34, in <module>
from scrapy.spiders import Spider
File "C:\Users\tzvia\Anaconda3\lib\site-packages\scrapy\spiders\__init__.py", line 10, in <module>
from scrapy.http import Request
File "C:\Users\tzvia\Anaconda3\lib\site-packages\scrapy\http\__init__.py", line 11, in <module>
from scrapy.http.request.form import FormRequest
File "C:\Users\tzvia\Anaconda3\lib\site- 
packages\scrapy\http\request\form.py", line 11, in <module>
import lxml.html
File "C:\Users\tzvia\Anaconda3\lib\site-packages\lxml\html\__init__.py", 
line 54, in <module>
from .. import etree
ImportError: DLL load failed: The specified module could not be found.

我尝试安装lxml,然后再次出现“失败,错误代码1”。

有人可以帮助我吗? 我使用python 3.6.1和Windows 10

2 个答案:

答案 0 :(得分:0)

在Windows上安装lxml可能会有些麻烦。

您可能想查看他们在其站点here上的信息。他们建议,如果从源构建失败,则可能要通过从here下载并运行

来使用非官方的预构建二进制文件
python -m pip install .\lxml-4.2.5-cp37-cp37m-win32.whl

确保下载所需的版本。如果您使用的是python 3.6,则应该获取cp36

答案 1 :(得分:0)

我认为这是因为您的Twisted安装失败。
https://www.lfd.uci.edu/~gohlke/pythonlibs/#twisted下载Twisted .whl文件。

然后运行

pip install <Twisted-your-version.whl>