5

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?

Community
  • 1
  • 1
J0ANMM
  • 7,849
  • 10
  • 56
  • 90
  • I'm also new to Scrapy, but I don't see the reason that you need to import scrapy outside of the project or the scrapy shell. You may want to expound about your problem. See 'runspider' if it's close to what you are looking for. – f123 May 16 '16 at 15:12
  • The aim is to use it inside a project, but I am receiving the import error when I am trying to run the python code that includes scrapy. For simplification I thought it would be easier just to show how the error coming directly when running python code in the Terminal. Everything else seems to me not relevant if scrapy is not imported in python. – J0ANMM May 16 '16 at 16:30
  • Working solution can be found in the following thread: _[Modules are installed using pip on OSX but not found when importing](http://stackoverflow.com/questions/37341614/modules-are-installed-using-pip-on-osx-but-not-found-when-importing)_, as the problem was not only with scrapy but with any module installed with pip. – J0ANMM May 20 '16 at 10:36

2 Answers2

3

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!

Colwin
  • 2,655
  • 3
  • 25
  • 25
Siyu Cao
  • 31
  • 3
1

Try to use import scrapy instead of import Scrapy

Polipizio
  • 46
  • 1
  • 5