7

我正在尝试为python2.6安装scrapy,但似乎进展不顺利。这是安装的软件包:

G:\Python26\Scripts>pip freeze
Scrapy==0.16.4
Twisted==12.3.0
libxml2-python==2.7.7
lxml==2.3.6
pyopenssl==0.13
w3lib==1.2
zope.interface==3.8.0

我也有 iconv 和 zlib。这是使用 pip 安装 scrapy 时的日志。我不知道我接下来应该做什么,我错过了什么吗?需要指导,谢谢。

win 7 64位,安装Visual C++

C:\Users\d>pip install scrapy
Downloading/unpacking scrapy
  Downloading Scrapy-0.16.4.tar.gz (679kB): 679kB downloaded
  Running setup.py egg_info for package scrapy
    warning: no files found matching 'license.txt' under directory 'scrapy'
    no previously-included directories found matching 'docs\build'
Requirement already satisfied (use --upgrade to upgrade): Twisted>=8.0 in g:\pyt
hon26\lib\site-packages (from scrapy)
Requirement already satisfied (use --upgrade to upgrade): w3lib>=1.2 in g:\pytho
n26\lib\site-packages (from scrapy)
Requirement already satisfied (use --upgrade to upgrade): lxml in g:\python26\li
b\site-packages\lxml-2.3.6-py2.6-win32.egg (from scrapy)
Requirement already satisfied (use --upgrade to upgrade): pyOpenSSL in g:\python
26\lib\site-packages\pyopenssl-0.13-py2.6-win32.egg (from scrapy)
Requirement already satisfied (use --upgrade to upgrade): zope.interface>=3.6.0
in g:\python26\lib\site-packages\zope.interface-3.8.0-py2.6-win32.egg (from Twis
ted>=8.0->scrapy)
Requirement already satisfied (use --upgrade to upgrade): setuptools in g:\pytho
n26\lib\site-packages (from zope.interface>=3.6.0->Twisted>=8.0->scrapy)
Installing collected packages: scrapy
  Running setup.py install for scrapy
    warning: no files found matching 'license.txt' under directory 'scrapy'
    no previously-included directories found matching 'docs\build'
Successfully installed scrapy
Cleaning up...


C:\Users\d>scrapy
Traceback (most recent call last):
  File "G:\Python26\lib\runpy.py", line 122, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "G:\Python26\lib\runpy.py", line 34, in _run_code
    exec code in run_globals
  File "G:\Python26\lib\site-packages\scrapy\cmdline.py", line 7, in <module>
    from scrapy.crawler import CrawlerProcess
  File "G:\Python26\lib\site-packages\scrapy\crawler.py", line 5, in <module>
    from scrapy.core.engine import ExecutionEngine
  File "G:\Python26\lib\site-packages\scrapy\core\engine.py", line 14, in <modul
e>
    from scrapy.core.downloader import Downloader
  File "G:\Python26\lib\site-packages\scrapy\core\downloader\__init__.py", line
16, in <module>
    from .middleware import DownloaderMiddlewareManager
  File "G:\Python26\lib\site-packages\scrapy\core\downloader\middleware.py", lin
e 7, in <module>
    from scrapy.http import Request, Response
  File "G:\Python26\lib\site-packages\scrapy\http\__init__.py", line 11, in <mod
ule>
    from scrapy.http.request.form import FormRequest
  File "G:\Python26\lib\site-packages\scrapy\http\request\form.py", line 9, in <
module>
    import lxml.html
  File "G:\Python26\lib\site-packages\lxml-2.3.6-py2.6-win32.egg\lxml\html\__ini
t__.py", line 12, in <module>
    from lxml import etree
ImportError: DLL load failed: %1 is not a valid Win32 application
4

8 回答 8

4

您需要按照此处的说明进行操作(也在上面列出)。

问题中列出的特定 DLL 错误是由于(至少在我的情况下)安装 32 位 OpenSSL 和 64 位其他所有内容。在我安装了正确的 OpenSSL 之后(顺便说一下,我不得不卸载上面链接中的所有包并开始为依赖项 msi 安装程序过度排序问题),scrapy 在 python27、windows7、64 位上运行良好。

于 2013-08-20T15:11:26.570 回答
1

阅读本指南以在 Windows 7 上安装 scrapy。egenix-pyopenssl 被列为必需的软件包,另外安装 pywin32 也可能有所帮助。

于 2013-02-08T08:07:47.263 回答
1

就我而言,我确实升级了导致此问题的python。
一个简单的scrapy升级就可以了

pip install --upgrade Scrapy

还要安装正确版本的 pywin: http ://doc.scrapy.org/en/latest/intro/install.html#windows

于 2015-10-27T09:14:57.837 回答
0

我在 Windows 10(64 位)上遇到了同样的问题。该错误可以通过以下方式在 Python 中重现:

>>> import OpenSSL
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "c:\Python27\lib\site-packages\OpenSSL\__init__.py", line 8, in <module>
    from OpenSSL import crypto, SSL
ImportError: DLL load failed: %1 is not a valid Win32 application.

安装 pyOpenSSL 后,我得到了错误ImportError: DLL load failed: The operating system cannot run %1.,这是通过复制libeay32.dllssleay32.dll到我的路径来解决的(是我的另一个答案)。

于 2017-11-22T21:31:54.500 回答
0

我的解决方案是pip install --upgrade PyopenSSL

于 2016-07-05T14:03:51.147 回答
0

我刚刚设法解决了这个问题,对于可能偶然发现这个问题的人来说,问题是你需要 PyWin32。对于 Windows 用户:

  1. pip install PyWin32 here,选择正确的python版本和32/64bit。现在在cmd中:

    pip install c:\users\desktop\pywin32-220.1-cp27-cp27m-win_amd64.whl

  2. 现在,安装 pywin32 系统文件,从提升的命令提示符运行“python.exe Scripts\pywin32_postinstall.py -install”。以管理员身份在命令提示符下 运行 cmd

    python "C:\Python27\Scripts\pywin32_postinstall.py" -install

于 2016-11-16T03:45:31.003 回答
-1

安装scrapy并不难。我刚刚在我的 64 位 Windows 7 机器上完成了它:

从http://python.org/download/安装 Python 2.7 :您需要调整 PATH 环境变量以包含 Python 可执行文件和其他脚本的路径。需要将以下路径添加到 PATH:

C:\Python2.7\;C:\Python2.7\Scripts\;

要更新 PATH,请打开命令提示符并运行:

c:\python27\python.exe c:\python27\tools\scripts\win_add2path.py

关闭命令提示符窗口并重新打开它以使更改生效,运行以下命令并检查它是否显示预期的 Python 版本:

python --version

https://pip.pypa.io/en/latest/installing.html安装 pip 现在打开命令提示符以检查 pip 是否安装正确:

pip --version

此时 Python 2.7 和 pip 包管理器必须工作,让我们安装 Scrapy:

pip install Scrapy

检查scrapy是否有效:

scrapy fetch http://www.google.com

这一切都源于:http://doc.scrapy.org/en/latest/intro/install.html

于 2014-10-22T14:17:45.640 回答
-1

我刚刚遇到了同样的问题,但我已经解决了。

请检查您安装的 Python 包的版本(32/64 位)是否与您的 Python 安装版本匹配。

由于我现在在一个 Scrapy 项目中工作并且我在我的计算机上安装了一个 64 位的 lxml 包,但是我刚刚发现我的计算机中 Python 的默认安装版本是 32 位。因此,版本不匹配,就会出现您发布的问题。

于 2016-11-08T09:50:53.510 回答