Error while starting new scrapy project

2020-06-16 10:01发布

问题:

I have installed Scrapy using Ubuntu packages provided in the Scrapy website. But on starting a Scrapy project

scrapy startproject test 

I am getting error message as.

 Traceback (most recent call last):   File "/usr/bin/scrapy", line 5,
 in <module>
     from pkg_resources import load_entry_point   File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 3084,
 in <module>
        File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 3070, in _call_aside
        File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 3097, in _initialize_master_working_set
        File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 653, in _build_master
        File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 666, in _build_from_requirements
        File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 844, in resolve
      pkg_resources.ContextualVersionConflict: (pyasn1 0.1.7 (/usr/lib/python2.7/dist-packages),
 Requirement.parse('pyasn1>=0.1.8'), set(['pyasn1-modules']))

Please help me solve this error. I am running Python 2.7.6

回答1:

According to the error:

pkg_resources.ContextualVersionConflict: (pyasn1 0.1.7 (/usr/lib/python2.7/dist-packages),
Requirement.parse('pyasn1>=0.1.8'), set(['pyasn1-modules']))

The required pyasn1 version should be greater or equal to 0.1.8 and you currently have installed in your global py2.7 dist-packages v0.1.7.

sudo pip install pyasn1 --upgrade will update your current pyasn1 package to the latest version and should solve the problem.

Note: you may wish to check that other projects or applications you have that depend on this library are still functioning correctly.

As a solution to the above notice, please have a look at creating virtualenv's for your python project as this will isolate dependant packages to your project (global ones remain unaffected). more information on virtualenv can be found HERE



回答2:

first you should visit https://pypi.python.org/pypi/pyasn1/ then download pyasn1-0.1.9-py2.7.egg (md5) and then execute easy_install pyasn1-0.1.9-py2.7.egg it works on my computer (CentOS 7)



回答3:

i just had exactly the same problem. it's something with not updated dependencies. try something like this:

sudo apt-get autoremove python

then:

apt-get install python

apt-get install python-scrapy



标签: python scrapy