windows下安装scrapy问题解决办法

时间:2022-01-27 16:24:57
 Scrapy是爬虫界大名鼎鼎的存在,在Linux下安装非常顺利,但是在Windows下确实非常多的问题发生,这里记录存在的各类问题以及如何解决。

1.   安装Scrapy失败
     直接在windows下安装scrapy大概率会是失败的,主要原因是各类依赖包未必全部安装,故依据具体的问题而定。
     >> pip install scrapy
2.  openssl 
Traceback (most recent call last):
  File "C:\ProgramData\Anaconda3\Scripts\scrapy-script.py", line 5, in <module>
    sys.exit(scrapy.cmdline.execute())
  File "C:\ProgramData\Anaconda3\lib\site-packages\scrapy\cmdline.py", line 128, in execute
    cmds = _get_commands_dict(settings, inproject)
  File "C:\ProgramData\Anaconda3\lib\site-packages\scrapy\cmdline.py", line 46, in _get_commands_dict
    cmds = _get_commands_from_module('scrapy.commands', inproject)
  File "C:\ProgramData\Anaconda3\lib\site-packages\scrapy\cmdline.py", line 29, in _get_commands_from_module
    for cmd in _iter_command_classes(module):
  File "C:\ProgramData\Anaconda3\lib\site-packages\scrapy\cmdline.py", line 19, in _iter_command_classes
    for module in walk_modules(module_name):
  File "C:\ProgramData\Anaconda3\lib\site-packages\scrapy\utils\misc.py", line 71, in walk_modules
    submod = import_module(fullpath)
  File "C:\ProgramData\Anaconda3\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "C:\ProgramData\Anaconda3\lib\site-packages\scrapy\commands\version.py", line 6, in <module>
    import OpenSSL
  File "C:\ProgramData\Anaconda3\lib\site-packages\OpenSSL\__init__.py", line 8, in <module>
    from OpenSSL import rand, crypto, SSL
  File "C:\ProgramData\Anaconda3\lib\site-packages\OpenSSL\rand.py", line 12, in <module>
    from OpenSSL._util import (
  File "C:\ProgramData\Anaconda3\lib\site-packages\OpenSSL\_util.py", line 6, in <module>
    from cryptography.hazmat.bindings.openssl.binding import Binding
  File "C:\ProgramData\Anaconda3\lib\site-packages\cryptography\hazmat\bindings\openssl\binding.py", line 12, in <module>
    from cryptography.hazmat.bindings._openssl import ffi, lib
ImportError: DLL load failed: 操作系统无法运行 %1。
解决办法:
 >>   pip3 uninstall pyopenssl
 >>  pip3 uninstall cryptography
 >>  pip3 install pyopenssl
  >>  pip3 install cryptography

   scrapy在Linux安装非常顺利,但是在Windows上却问题多多,一波三折,个人建议,如果玩开发,还是推荐linux或者mac。