python - Scrapy - Load a yaml file with a relative path inside the spider -
I am trying to implement my scrapy crawlers , but the problem is that my Pass yaml file is that I am trying to load from inside the , it works when the spider is loaded from the shell: scrapy crawl & lt; spider-name & gt; . But when the spider is deployed under scrapyd , the path of the yaml file should be complete . The relative path for code> has been posted on on scrapyd : scrapyd-deploy default -p & Lt; project-name & gt; Curl http://127.0.0.1:6800/schedule.json -d project = & lt; Project-name & gt; -D spider = & lt; Spider-name & gt; and the yaml file is loaded as: open ('../categories.yaml', 'r') F: Pass The relative path is relative to the current working directory (the directory that started with your script). If you want to load a file from a path relative to the current script location, then you can try the following: root_dir = os.path.abspath (os.path.dirname (__ file__) ) y...