新建scrapy项目报错

新手上路,请多包涵

在windows下成功安装scrapy和依赖包后:

C:\Users\daming\Desktop\scrapy>scrapy
Scrapy 1.5.1 - no active project

Usage:
  scrapy <command> [options] [args]

Available commands:
  bench         Run quick benchmark test
  fetch         Fetch a URL using the Scrapy downloader
  genspider     Generate new spider using pre-defined templates
  runspider     Run a self-contained spider (without creating a project)
  settings      Get settings values
  shell         Interactive scraping console
  startproject  Create new project
  version       Print Scrapy version
  view          Open URL in browser, as seen by Scrapy

  [ more ]      More commands available when run from project directory

Use "scrapy <command> -h" to see more info about a command

但是尝试运行scrapy startproject demo却出现如下错误:

C:\Users\daming\Desktop\scrapy>scrapy startproject demo
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 9, in <module>
  File "c:\python27\lib\site-packages\scrapy\cmdline.py", line 149, in execute
    cmd.crawler_process = CrawlerProcess(settings)
  File "c:\python27\lib\site-packages\scrapy\crawler.py", line 252, in __init__
    log_scrapy_info(self.settings)
  File "c:\python27\lib\site-packages\scrapy\utils\log.py", line 149, in log_scrapy_info
    for name, version in scrapy_components_versions()
  File "c:\python27\lib\site-packages\scrapy\utils\versions.py", line 35, in scrapy_components_versions
    ("pyOpenSSL", _get_openssl_version()),
  File "c:\python27\lib\site-packages\scrapy\utils\versions.py", line 43, in _get_openssl_version
    import OpenSSL
  File "c:\python27\lib\site-packages\OpenSSL\__init__.py", line 8, in <module>
    from OpenSSL import crypto, SSL
  File "c:\python27\lib\site-packages\OpenSSL\crypto.py", line 12, in <module>
    from cryptography import x509
  File "c:\python27\lib\site-packages\cryptography\x509\__init__.py", line 7, in <module>
    from cryptography.x509 import certificate_transparency
ImportError: cannot import name certificate_transparency

求大佬解答

阅读 2.8k
2 个回答

重新安装试试pip install cryptography

重装三步走:

1、重装子模块
2、重装模块
3、重装Python

更新四步走(不要尝试把Python2更新到Python3)

1、更新子模块
2、更新模块
3、更新pip
4、更新Python

========================

首先除非Python环境坏了,否则 runpy.py 是不会出错的,
再除非模块坏了,不然scrapy是可以正常运作的,
但通过“三步走”和“四步走”表明这样的情况都不可能发生,
基本看来,就是子模块未安装(未更新、未安装完全)的问题了。

========================

scrapy 的 execution file(可执行文件)不一定能在你那个版本的Windows上运行,
还有可能是防火墙问题,(不让scrapy的服务器通过)
冒昧的问一句,我用的是Python3,OpenSSL模块常出问题,您的错误代码中有提到过OpenSSL,会不会是依赖库没有安装?

========================

Python2 对我来说的未知因素还有很多,希望楼主采纳,又有几个新想法:
您能否使用IDLE来编写Scrapy程序?
如果能,那您就使用IDLE来编。
如果不能,在网上有很多比我更牛的人,他们说不定会有解决方法。
您能否使用其它基于Scrapy或和Scrapy有同样依赖库的模块?
如果不能,那就尝试完全重装模块,包括子模块。

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题