title: Run custom Django management command over SSH
body: <p>I have a Django application with a custom management command in one of the apps. If I log in over SSH I can run it without any problems with</p>
  
  <blockquote>
    <p>python manage.py sitedir/mycommand</p>
  </blockquote>
  
  <p>However, if I try to run the command as a oneliner from my local box like this:</p>
  
  <blockquote>
    <p>ssh myserver python manage.py sitedir/mycommand</p>
  </blockquote>
  
  <p>I get an ImportError like this:</p>
  
  <pre><code>Traceback (most recent call last):
    File "mysite/manage.py", line 11, in &lt;module&gt;
      execute_manager(settings)
    File "/usr/lib/python2.5/site-packages/django/core/management/__init__.py", line 438, in execute_manager
      utility.execute()
    File "/usr/lib/python2.5/site-packages/django/core/management/__init__.py", line 379, in execute
      self.fetch_command(subcommand).run_from_argv(self.argv)
    File "/usr/lib/python2.5/site-packages/django/core/management/__init__.py", line 261, in fetch_command
      klass = load_command_class(app_name, subcommand)
    File "/usr/lib/python2.5/site-packages/django/core/management/__init__.py", line 67, in load_command_class
      module = import_module('%s.management.commands.%s' % (app_name, name))
    File "/usr/lib/python2.5/site-packages/django/utils/importlib.py", line 35, in import_module
      __import__(name)
  ImportError: No module named mysite.myapp.management.commands.mycommand
  </code></pre>
  
  <p>The real reason is that I want to run this admin command from a Fabric script but until I can get it to run via the ssh one-liner I guess it will be impossible. Is there something in the environment that differs when you run it via the ssh one-liner? The python path seems correct in both cases.</p>