title: Scrapy Custom Project Command: "ImportError: No module named commands"
body: <p>I am trying to make a Scrapy custom project command to run spiders. I found <a href="http://doc.scrapy.org/en/master/topics/commands.html?highlight=commands_module#register-commands-via-setup-py-entry-points" rel="nofollow">Register commands via setup.py entry points</a> and did the following:</p>
  
  <ol>
  <li><p><code>mkdir commands</code></p></li>
  <li><p><code>cd commands</code></p></li>
  <li><p>Created the command file <code>crawlall.py</code>:</p>
  
  <pre><code>from scrapy.commands import ScrapyCommand
  from scrapy.utils.project import get_project_settings
  from scrapy.crawler import Crawler
  
  class Command(ScrapyCommand):
  
      requires_project = True
  
      def syntax(self):
          return '[options]'
  
      def short_desc(self):
          return 'Runs all of the spiders'
  
      def run(self, args, opts):
          settings = get_project_settings()
  
          for spider_name in self.crawler.spiders.list():
              crawler = Crawler(settings)
              crawler.configure()
              spider = crawler.spiders.create(spider_name)
              crawler.crawl(spider)
              crawler.start()
  
          self.crawler.start()
  </code></pre></li>
  <li><p>Added <code>COMMANDS_MODULE = 'myprojectname.commands'</code> to the <code>settings.py</code>.</p></li>
  <li><p>Created the <code>setup.py</code>:</p>
  
  <pre><code>from setuptools import setup, find_packages
  
  setup(name='scrapy-mymodule',
    entry_points={
      'scrapy.commands': [
        'crawlall=cnblogs.commands:crawlall',
      ],
    },
   )
  </code></pre></li>
  <li><p>Ran the project command with <code>scrapy crawlall</code>, which threw the following error:</p>
  
  <pre><code>Traceback (most recent call last):
    File "/usr/local/bin/scrapy", line 9, in &lt;module&gt;
      load_entry_point('Scrapy==1.0.0rc2', 'console_scripts', 'scrapy')()
    File "/usr/local/lib/python2.7/site-packages/Scrapy-1.0.0rc2-py2.7.egg/scrapy/cmdline.py", line 122, in execute
      cmds = _get_commands_dict(settings, inproject)
    File "/usr/local/lib/python2.7/site-packages/Scrapy-1.0.0rc2-py2.7.egg/scrapy/cmdline.py", line 50, in _get_commands_dict
      cmds.update(_get_commands_from_module(cmds_module, inproject))
    File "/usr/local/lib/python2.7/site-packages/Scrapy-1.0.0rc2-py2.7.egg/scrapy/cmdline.py", line 29, in _get_commands_from_module
      for cmd in _iter_command_classes(module):
    File "/usr/local/lib/python2.7/site-packages/Scrapy-1.0.0rc2-py2.7.egg/scrapy/cmdline.py", line 20, in _iter_command_classes
      for module in walk_modules(module_name):
    File "/usr/local/lib/python2.7/site-packages/Scrapy-1.0.0rc2-py2.7.egg/scrapy/utils/misc.py", line 63, in walk_modules
      mod = import_module(path)
    File "/usr/local/lib/python2.7/importlib/__init__.py", line 37, in import_module
      __import__(name)
  ImportError: No module named commands
  </code></pre></li>
  </ol>
  
  <p>What should I do? Where is my mistake?</p>