python - scrapy无法初始化项目
PHPz
PHPz 2017-04-17 18:00:50
0
3
403

在交互环境


import scrapy    # 成功

但是在终端 scrapy 新建项目就出错了

Traceback (most recent call last):
  File "/usr/local/bin/scrapy", line 7, in <module>
    from scrapy.cmdline import execute
  File "/usr/local/lib/python2.7/dist-packages/scrapy/cmdline.py", line 9, in <module>
    from scrapy.crawler import CrawlerProcess
  File "/usr/local/lib/python2.7/dist-packages/scrapy/crawler.py", line 15, in <module>
    from scrapy.signalmanager import SignalManager
  File "/usr/local/lib/python2.7/dist-packages/scrapy/signalmanager.py", line 2, in <module>
    from pydispatch import dispatcher
ImportError: No module named pydispatch

可是, pydispatch包已经有了呀!

$ pip install --upgrade pydispatch

Requirement already up-to-date: pydispatch in /usr/local/lib/python2.7/dist-packages
Requirement already up-to-date: colorama>=0.2.7 in /usr/local/lib/python2.7/dist-packages (from pydispatch)
Requirement already up-to-date: six>=1.5.2 in /usr/local/lib/python2.7/dist-packages (from pydispatch)
PHPz
PHPz

学习是最好的投资!

reply all(3)
阿神

Is there something wrong with the environment setup?
Check whether there is an installation package in your problematic code:

>>> import pip
>>> installed_packages = pip.get_installed_distributions()
>>> installed_packages_list = sorted(["%s==%s" % (i.key, i.version)
...      for i in installed_packages])
>>> print(installed_packages_list)

Method taken from:
http://stackoverflow.com/questions/739993/how-can-i-get-a-list-of-locally-installed-python-modules

PHPzhong

I checked Scrapy’s Release notes and found

The previously bundled scrapy.xlib.pydispatch library was deprecated and replaced by pydispatcher.

That is to say, the latest version of scrapy does not use the pydispatch module, but uses the pydispatcher module
So maybe you are not using the latest scrapy?
As a solution, I suggest you use virtualenv to build an independent python environment. Reinstall the latest scrapy in this environment.
or reinstall scrapy directly in the system

小葫芦

pip install PyDispatcher

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template