在win 7(64位)上安装scrapy

时间:2013-02-08 04:33:43

标签: python windows-7 install scrapy

我正在尝试为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

8 个答案:

答案 0 :(得分:4)

您需要按照here的说明(也在上面列出)。

问题中列出的特定DLL错误是(至少在我的情况下)安装32位OpenSSL与64位其他所有。在我安装了正确的OpenSSL之后(并且顺便说一下,必须卸载上面链接中的所有软件包并开始依赖msi安装程序的过度事务),scrapy在python27,windows7,64位上工作正常。

答案 1 :(得分:1)

仔细阅读guide to installing scrapy on Windows 7。 egenix-pyopenssl被列为必需的包,加上安装pywin32也可以提供帮助。

答案 2 :(得分:1)

在我的情况下,我确实升级了python导致了这个问题 一个简单的scrapy升级做了诀窍

  

pip install --upgrade Scrapy

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

答案 3 :(得分:0)

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

答案 4 :(得分: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作为 admin 运行并在命令提示符下运行
      

    python“C:\ Python27 \ Scripts \ pywin32_postinstall.py”-install

答案 5 :(得分: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复制到我的路径(here我的另一个答案)来解决的。

答案 6 :(得分:-1)

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

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 --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

答案 7 :(得分:-1)

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

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

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