Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ImportError: No module named Scrapy; even if Scrapy was successfully installed

Tags:

I am trying to use Scrapy in Python, but even if it is installed, afterwards it is not found when I try import it. I am quite new at python and dealing directly with the Terminal, so probably I am missing one (or many) important points.

Details

This is what I get in the Terminal about the installation of Scrapy:

$ pip install Scrapy
Collecting Scrapy
Using cached Scrapy-1.1.0-py2.py3-none-any.whl
Requirement already satisfied (use --upgrade to upgrade): six>=1.5.2 in /usr/local/lib/python2.7/site-packages (from Scrapy)
...
Requirement already satisfied (use --upgrade to upgrade): pycparser in /usr/local/lib/python2.7/site-packages (from cffi>=1.4.1->cryptography>=1.3->pyOpenSSL->Scrapy)
Installing collected packages: Scrapy
Successfully installed Scrapy-1.1.0

But then, when I want to import it, it is not found:

$ python
Python 2.7.5 (default, Mar  9 2014, 22:15:05) 
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import Scrapy
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named Scrapy

Note that when I try to import scrapy inside a project, once I run it I receive the same error than trying to import scrapy directly in the Terminal.

I am on OS X version 10.9.5.

Approach tried

I am able to start a new project. For instance:

$ scrapy startproject tutorial

will be run successfully.

This make me think that the problem is somewhere in the link between scrapy and python, not in the installation of scrapy itself.

Documentation found so far

I have not found any additional information in the official documentation.

I have also looked in Stackoverflow and Google for similar problems, but did not find any helpful answer. Probably I am looking for the wrong keywords. The following topic seemed to be a similar problem, but I actually do not have any problem running pip nor did I get any error related to Cryptography.

Could anybody point me in the right direction?

like image 393
J0ANMM Avatar asked May 15 '16 16:05

J0ANMM


1 Answers

I meet the same questions of that. Finally, I find that there are two python lib in my computer.

The scrapy was installed in the

D:\Python\IDE\Lib\site-packages. 

But, python used the python lib in

D:\Python\Python 2.7\Lib\site-packages. 

So, you install the scrapy success. But, the python use a wrong path to connect it. So, you may change the python path of the lib in the software or copy the scrapy to the python lib that your software use! I wish it can help you!

like image 138
Siyu Cao Avatar answered Sep 28 '22 04:09

Siyu Cao