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
python manage.py sitedir/mycommand
However, if I try to run the command as a oneliner from my local box like this:
ssh myserver python manage.py sitedir/mycommand
I get an ImportError like this:
Traceback (most recent call last):
File "mysite/manage.py", line 11, in <module>
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
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.