我知道这个问题已被提出,但我没有找到解决方案。我正在尝试按照有关在django应用程序中集成Scrapy项目的教程。当我尝试运行" scrapy crawl particip"它给了我一个关于(django)设置的导入错误。这是我的文件夹树:
├── __init__.py
├── manage.py
├── mappingsite
│ ├── __init__.py
│ ├── settings.py
│ ├── urls.py
│ └── wsgi.py
├── storedirectoryscraper
│ ├── scrapy.cfg
│ └── storedirectoryscraper
│ ├── __init__.py
│ ├── __init__.pyc
│ ├── items.py
│ ├── pipelines.py
│ ├── settings.py
│ ├── settings.pyc
│ └── spiders
│ ├── __init__.py
│ └── particip.py
└── storemapapp
├── admin.py
├── apps.py
├── __init__.py
├── migrations
│ └── __init__.py
├── models.py
├── tests.py
└── views.py
storedirectoryscraper.settings文件中的相关代码(Scrapy设置):
sys.path.append('<abs path to BloggerWorkspace/mappingsite>')
os.environ['DJANGO_SETTINGS_MODULE'] = 'mappingsite.settings'
django.setup()
BOT_NAME = 'storedirectoryscraper'
如何定义文件的正确路径以及为什么?
[编辑]
我的错误追溯:
(BloggerWorkspace) popovvasile@popovvasile:~/work/BloggerWorkspace/mappingsite/storedirectoryscraper$ scrapy crawl particip
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)
File "/home/popovvasile/work/BloggerWorkspace/mappingsite/storedirectoryscraper/storedirectoryscraper/settings.py", line 23, in <module>
django.setup()
File "/usr/local/lib/python2.7/dist-packages/django/__init__.py", line 17, in setup
configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
File "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py", line 55, in __getattr__
self._setup(name)
File "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py", line 43, in _setup
self._wrapped = Settings(settings_module)
File "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py", line 99, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
ImportError: No module named mappingsite.settings