title: Running scrapy from python script
body: <p>ive been trying to run scrapy from a python script file because i need to get the data and save it into my db. but when i run it with scrapy command</p>
  
  <pre><code>scrapy crawl argos
  </code></pre>
  
  <p>the script runs fine
  but when im trying to run it with a script, following this link</p>
  
  <pre><code>http://doc.scrapy.org/en/latest/topics/practices.html#run-scrapy-from-a-script
  </code></pre>
  
  <p>i get this error</p>
  
  <pre><code>$ python pricewatch/pricewatch.py update
  Traceback (most recent call last):
    File "pricewatch/pricewatch.py", line 39, in &lt;module&gt;
      main()
    File "pricewatch/pricewatch.py", line 31, in main
      update()
    File "pricewatch/pricewatch.py", line 24, in update
      setup_crawler("argos.co.uk")
    File "pricewatch/pricewatch.py", line 13, in setup_crawler
      settings = get_project_settings()
    File "/Library/Python/2.7/site-packages/Scrapy-0.22.2-py2.7.egg/scrapy/utils/project.py", line 58, in get_project_settings
      settings_module = import_module(settings_module_path)
    File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py", line 37, in import_module
      __import__(name)
  ImportError: No module named settings
  </code></pre>
  
  <p>i am unable to understand why it doesnt found get_project_setting() but runs fine with scrapy command on terminal</p>
  
  <p>here is the screen shot of my project</p>
  
  <p><img src="https://i.stack.imgur.com/5Kx1h.png" alt="enter image description here"></p>
  
  <p>here is the pricewatch.py code:</p>
  
  <pre><code>import commands
  import sys
  from database import DBInstance
  from twisted.internet import reactor
  from scrapy.crawler import Crawler
  from scrapy import log
  from spiders.argosspider import ArgosSpider
  from scrapy.utils.project import get_project_settings
  import settings
  
  def setup_crawler(domain):
      spider = ArgosSpider(domain=domain)
      settings = get_project_settings()
      crawler = Crawler(settings)
      crawler.configure()
      crawler.crawl(spider)
      crawler.start()
  
  def update():
      #print "Enter a product to update:"
      #product = raw_input()
      #print product
      #db = DBInstance()
      setup_crawler("argos.co.uk")
      log.start()
      reactor.run()
  
  def main():
      try:
          if sys.argv[1] == "update":
              update()
          elif sys.argv[1] == "database":
              #db = DBInstance()
      except IndexError:
          print "You must select a command from Update, Search, History"
  
  
  if  __name__ =='__main__':
      main()
  </code></pre>