为什么会出现“ DLL加载失败:%1不是有效的Win32应用程序”错误?

时间:2018-07-02 18:39:22

标签: python scrapy

我正在尝试使用scrapy python库,但遇到了问题。我正在按照Python Application Development Using Scrapy上的一个小教程并使用此代码

import scrapy

class QuotesSpider(scrapy.Spider):
name = "quotes"
start_urls = [
    'http://quotes.toscrape.com/tag/humor/',
]

def parse(self, response):
    for quote in response.css('div.quote'):
        yield {
            'text': quote.css('span.text::text').extract_first(),
            'author': quote.xpath('span/small/text()').extract_first(),
        }

    next_page = response.css('li.next a::attr("href")').extract_first()
    if next_page is not None:
        yield response.follow(next_page, self.parse)

我使用命令scrapy runspider quotes_spider.py -o quotes.json运行它,并看到此输出

Traceback (most recent call last):
 File "c:\python27\lib\runpy.py", line 174, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "c:\python27\lib\runpy.py", line 72, in _run_code
exec code in run_globals
File "C:\Python27\Scripts\scrapy.exe\__main__.py", line 5, in <module>
File "c:\python27\lib\site-packages\scrapy\__init__.py", line 34, in <module>
from scrapy.spiders import Spider
File "c:\python27\lib\site-packages\scrapy\spiders\__init__.py", line 10, in <module>
from scrapy.http import Request
File "c:\python27\lib\site-packages\scrapy\http\__init__.py", line 11, in <module>
from scrapy.http.request.form import FormRequest
File "c:\python27\lib\site-packages\scrapy\http\request\form.py", line 11, in <module>
import lxml.html
File "c:\python27\lib\site-packages\lxml\html\__init__.py", line 54, in <module>
from .. import etree
ImportError: DLL load failed: %1 is not a valid Win32 application.

为什么我会收到这些错误?

我正在使用Python 2.7的64位版本,我认为scrapy也是64位的,但我不确定。任何帮助,将不胜感激!

编辑:删除lxml库并重新安装它们是针对此特定问题的解决方法

0 个答案:

没有答案