Popov Dmytro
Popov Dmytro

Reputation: 51

python scrapy does not working - "ImportError: No module named settings"

scrappy lib in /usr/lib/python2.7/site-packages/scrapy
my project catalog:

.../projects/scrapy                                       
.../projects/parser_module                                     
....../projects/parser_module/parser  
....../projects/parser_module/parser           
........../projects/parser_module/parser/spiders/.....     
........../projects/parser_module/parser/<files etc>   
....../projects/parser_module/scrapy.cfg

In directory .../projects/parser_module/ I am set command scrapy crawl parser and get result:

Traceback (most recent call last):                                                                   

 File "/usr/bin/scrapy", line 4, in <module>                                                         
   execute()                                                                                         
  File "/usr/lib/python2.7/site-packages/scrapy/cmdline.py", line 109, in execute  
  settings = get_project_settings() 
  File "/usr/lib/python2.7/site-packages/scrapy/utils/project.py", line 60, in get_project_settings  
    settings.setmodule(settings_module_path, priority='project')          
  File "/usr/lib/python2.7/site-packages/scrapy/settings/__init__.py", line 108, in setmodule        
    module = import_module(module)                                                                   
  File "/usr/lib64/python2.7/importlib/__init__.py", line 37, in import_module                       
    __import__(name)                                                                                 
ImportError: No module named settings  

Can you please tell me how to solve the problem?

Upvotes: 5

Views: 16222

Answers (4)

ChillMouse
ChillMouse

Reputation: 9

I found myself problem, next is solve:

My project name is: superproject

I recieved problem "ImportError: No module named project"

In my settings.py was row ROTATING_PROXY_BAN_POLICY = 'project.policy.BanPolicy'.

Warning! Projects name is different. In settings.py yours names must be like superproject and dependency.

If rename ROTATING_PROXY_BAN_POLICY = 'project.policy.BanPolicy' TO => ROTATING_PROXY_BAN_POLICY = 'superproject.policy.BanPolicy', THEN prolem was solving.

Upvotes: -1

user8066566
user8066566

Reputation: 81

I had the same issue. Solved by removing the init.pyc file which was present just inside the scrapy project directory

Upvotes: 0

piawine
piawine

Reputation: 11

To solve "ImportError: No module named *.settings", try to change project name and related settings in scrapy.cfg

Upvotes: 1

Frederic Bazin
Frederic Bazin

Reputation: 1529

to avoid such issue create your project folder with scrapy startproject parser_module

now to fix your issue, you either have a fresh start or create a dummy project with scrapy startproject to copy setting.py from. Then maybe next error you will find other missing file in this folder.

This is the typical structure of a scrapy project.

.
├── scrapy.cfg
└── project_name
    ├── __init__.py
    ├── items.py
    ├── settings.py
    └── spiders
        └── __init__.py
            spider.py

Upvotes: 5

Related Questions