South: Unknown command 'migrate'

18,253

Solution 1

Successful import of package is not enough for Django management commands. Python can import a package easy from a zipped egg but Django needs a normal uncompressed file.

Advices that simplify your problem initially:

  1. Management commands must exist as files in a normal directory path..to..south/management/commands (not zipped).
  2. Try to find and remove old installations of south manually. A frequent problem was that one version of some package has been installed by easy_install (zipped) or manually by "python setup.py install" but pip didn't uninstall it and installed it for the second time.
  3. Use only absolute directories in python path. Do not change the python path between installer and running Django either in environment or by customized manage or settings.py if possible. Some manage.py or settings.py use different python path than the one used by package intallers, e.g. added "." or ".." before other directories. You should not have other south directory in . or .. in your project.

The advice 1 is an absolute requirement of Django. The other two are heplful even if I use multiple versions somehow for testing my applications with multiple versions of Python, Django etc.

Example of investigation of the main requirement:

$ python manage.py shell
>>> import os
>>> import south.management.commands.migrate
>>> assert os.path.isfile(south.management.commands.migrate.__file__)

Solution 2

This is caused largely by following the 1.7 (DEV version) tutorial when we all get the last stable version (1.6) installed by pip.

Either follow the 1.6 tutorial or follow the instructions to install 1.7 dev version of Django.

Solution 3

I solved this problem by going here http://south.readthedocs.org/en/latest/installation.html and using easy_install south. I then added 'south', to my INSTALLED_APPS and it worked.

Solution 4

I got the same error, but for a different reason. I did:

$ python manage.py migrate my_app --settings=settings_dev.py

But with the settings parameter, you should pass the name of the module not the name of the file. So it should have been

$ python manage.py migrate my_app --settings=settings_dev

You get a decent error message when you run the validate command like that, but when you run a south command, it'll say the command is unknown :/

Share:
18,253
Alexandre
Author by

Alexandre

Updated on July 09, 2022

Comments

  • Alexandre
    Alexandre almost 2 years

    I'm getting a merciless

    $ python manage.py migrate
    Unknown command: 'migrate'
    Type 'manage.py help' for usage.
    

    I pulled the code from github onto a fresh computer. This code is tested and is working on other computers. The entire code runs fine except for the fact I can't run migrations!

    Installed my virtual environment and ran pip install -r requirements.txt. It installs everything, including South. I can check by running

    $ python manage.py shell
    >>> import south
    >>> south.__version__
    '0.7.3'
    

    However, when I run the manage.py help, the migrate and schemamigration commands don't appear listed.

    I double checked that my settings.py file has 'south' listed under INSTALLED_APPS (I didn't change this file after pulling).

    I tried pip uninstall south and then running pip install -r requirements.txt again, but I still get the same error.

    Would really appreciate any help!

  • Alexandre
    Alexandre over 11 years
    hynekcer, using your suggestion, I'm getting import south.management.commands.migrate >>> ImportError: No module named migrate
  • Alexandre
    Alexandre over 11 years
    Perfect! It's figured out and working. I had a folder called "south" in .. Before, we were storing South stuff there, but later we decided to use pip. We removed that folder, but somehow the deletion must have not been versioned. Thanks!
  • Oleg Belousov
    Oleg Belousov over 10 years
    The assert is succeeding, but I still cannot migrate
  • hynekcer
    hynekcer over 10 years
    @OlegTikhonov: A new question for someone else can be better after so long time. The original question is related to the message "Unknown command: 'migrate'", with more context related to the answer. Evidently you have not exactly the same problem as in the question, because you have the opposite test result. It is very strange if you see the same error message, but you can pass the test example immediately without changing anything except "shell" <-> "migrate". Think about it.
  • Oleg Belousov
    Oleg Belousov over 10 years
    Yes I know, I just don't want to ask noobish questions, anyways I just used manage.y and everything works now. And you got an upvote for me for your detailed explanation