2016-07-25 92 views
0

我試圖運行任何代碼scrapy我得到這個錯誤,不知道爲什麼導入設置

Traceback (most recent call last): 
    File "/usr/local/bin/scrapy", line 11, in <module> 
    sys.exit(execute()) 
    File "/usr/local/lib/python2.7/dist-packages/scrapy/cmdline.py", line 108, in execute 
    settings = get_project_settings() 
    File "/usr/local/lib/python2.7/dist-packages/scrapy/utils/project.py", line 60, in get_project_settings 
    settings.setmodule(settings_module_path, priority='project') 
    File "/usr/local/lib/python2.7/dist-packages/scrapy/settings/__init__.py", line 282, in setmodule 
    module = import_module(module) 
    File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module 
    __import__(name) 
ImportError: No module named settings 

誰能幫我這個

回答

0

好像scrapy,如果你在你的項目文件夾使用tree命令找不到settings.py文件在您scrapy項目目錄

. 
├── scrapy.cfg 
└── projectname 
    ├── __init__.py 
    ├── items.py 
    ├── settings.py # Is this file here? 
    └── spiders 
     ├── __init__.py 
     ├── test_spider_one.py 

你能看到那裏的文件嗎?也許它被刪除或名稱錯誤?

還要確保您已在scrapy.cfg 設置正確的值,即它應該是這個樣子:

[settings] 
default = projectname.settings 
+0

├──scrapy.cfg ├──嘰嘰喳喳 │├──__init__.py │├──__init __。PYC │├──items.py │├──items.pyc │├──pipelines.py │├──settings.py │├──settings.pyc │└──蜘蛛 │├──__init__.py │├──__init __。PYC │├──twitterimpression.py │├──twitterimpression.pyc │├─ ─twitterlocation.py │├──twitterlocation.pyc │├──twitterscrape.py │└──twitterscrape.pyc └──updated_test.csv 文件即settings.py BOT_NAME ='Twitter的 內部SPIDER_MODULES = ['twitter.spiders'] NEWSPIDER_MODULE ='twitter.spiders' –

+0

@KanakSharma,你能用這個'tree'輸出來編輯你的問題嗎?在這裏的評論,這是非常難以閱讀 –

+0

我粘貼它,但不知道它爲什麼只用這種格式 –

0
├── followers.csv 
├── homepage.csv 
├── organic.csv 
├── scrapy.cfg 
├── twitter 
│   ├── __init__.py 
│   ├── __init__.pyc 
│   ├── items.py 
│   ├── items.pyc 
│   ├── pipelines.py 
│   ├── settings.py 
│   ├── settings.pyc 
│   └── spiders 
│    ├── __init__.py 
│    ├── __init__.pyc 
│    ├── twitterimpression.py 
│    ├── twitterimpression.pyc 
│    ├── twitterlocation.py 
│    ├── twitterlocation.pyc 
│    ├── twitterscrape.py 
│    └── twitterscrape.pyc 
└── updated_test.csv 
+0

你應該把它放在你的問題中,下面有一個編輯按鈕。 – Granitosaurus