Question

I am trying to set IMAGES_STORE as a relative path but i am getting error and if i am specifying IMAGES_STORE as a Full path it is working fine /home/vaibhav/scrapyprog/comparison/eScraperInterface/images

Error i am getting is at link Actually it is giving me RuntimeError: OSError: [Errno 20] Not a directory: '/tmp/eScraper-1371463750-Lm8HLh.egg/images' error but if i set Full IMAGE_STORE path it is working fine can someone tell me how can i specify relative path...as i need to deploy this project at various system ...that's why i need relative path....

import os
#------------------------------------------------------------------------------ 

projectDirPath = os.path.abspath(os.path.dirname((os.path.dirname(__file__))))
imagesDIRPath =  projectDirPath + "/images"

BOT_NAME = 'eScraper'
DOWNLOADER_DEBUG = True
CONCURRENT_REQUESTS = 200
AUTOTHROTTLE_DEBUG = True
AUTOTHROTTLE_ENABLED= True
DEPTH_STATS_VERBOSE = True

SPIDER_MODULES = ['eScraper.spiders']
NEWSPIDER_MODULE = 'eScraper.spiders'
COMMANDS_MODULE = 'eScraper.commands'
ITEM_PIPELINES = ['eScraper.pipelines.EscraperPipeline',
                  'eScraper.pipelines.MySQLStorePipeline']

IMAGES_STORE = imagesDIRPath


DOWNLOADER_MIDDLEWARES = {
                          'eScraper.rotate_useragent.RotateUserAgentMiddleware' :400,
                          'scrapy.contrib.downloadermiddleware.useragent.UserAgentMiddleware' : None
                          }


#------------------------------------------------------------------------------

My project structure:

├── eScraperInterface
│   ├── build
│   │   ├── bdist.linux-i686
│   │   └── lib.linux-i686-2.7
│   │       ├── eScraper
│   │       │   ├── commands
│   │       │   │   ├── __init__.py
│   │       │   │   └── runAllSpiders.py
│   │       │   ├── __init__.py
│   │       │   ├── items.py
│   │       │   ├── pipelines.py
│   │       │   ├── rotate_useragent.py
│   │       │   ├── settings.py
│   │       │   ├── spiders
│   │       │   └── userAgentList.py
│   │       ├── eScraperInterface
│   │       │   ├── __init__.py
│   │       │   ├── settings.py
│   │       │   ├── urls.py
│   │       │   └── wsgi.py
│   │       └── eScraperInterfaceApp
│   │           ├── __init__.py
│   │           ├── models.py
│   │           ├── tests.py
│   │           └── views.py
│   ├── checkImageExist.py
│   ├── eScraper
│   │   ├── commands
│   │   │   ├── __init__.py
│   │   │   ├── __init__.pyc
│   │   │   ├── runAllSpiders.py
│   │   │   └── runAllSpiders.pyc
│   │   ├── __init__.py
│   │   ├── __init__.pyc
│   │   ├── items.py
│   │   ├── items.pyc
│   │   ├── pipelines.py
│   │   ├── pipelines.pyc
│   │   ├── rotate_useragent.py
│   │   ├── rotate_useragent.pyc
│   │   ├── settings.py
│   │   ├── settings.py~
│   │   ├── settings.pyc
│   │   ├── spiders
│   │   ├── userAgentList.py
│   │   └── userAgentList.pyc
│   ├── eScraperInterface
│   │   ├── __init__.py
│   │   ├── __init__.pyc
│   │   ├── settings.py
│   │   ├── settings.pyc
│   │   ├── urls.py
│   │   ├── urls.pyc
│   │   ├── wsgi.py
│   │   └── wsgi.pyc
│   ├── eScraperInterfaceApp
│   │   ├── __init__.py
│   │   ├── __init__.pyc
│   │   ├── models.py
│   │   ├── models.py~
│   │   ├── models.pyc
│   │   ├── tests.py
│   │   └── views.py
│   ├── images
│   ├── __init__.py
│   ├── manage.py
│   ├── project.egg-info
│   │   ├── dependency_links.txt
│   │   ├── entry_points.txt
│   │   ├── PKG-INFO
│   │   ├── SOURCES.txt
│   │   └── top_level.txt
│   ├── scrapy.cfg
│   └── setup.py
├── README.txt
└── README.txt~
Was it helpful?

Solution

Assuming you've provided settings.py from eScraperInterface/eScraper/settings.py:

CUR_DIR = os.path.dirname(os.path.realpath(__file__))
IMAGES_STORE = os.path.join(CUR_DIR, '..', 'images')

Hope that helps.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top