South: Unknown command 'migrate'

后端 未结 6 1287
不知归路
不知归路 2021-01-11 18:04

I\'m getting a merciless

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

I pulled the code from

相关标签:
6条回答
  • 2021-01-11 18:17

    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__)
    
    0 讨论(0)
  • 2021-01-11 18:19

    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 :/

    0 讨论(0)
  • 2021-01-11 18:26

    In my case. south was already installed but later on requirements was the cause for other libraries:

    pip install -r requirements.txt
    

    I don't know why manage.py didn't complain about them.

    0 讨论(0)
  • 2021-01-11 18:31

    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.

    0 讨论(0)
  • 2021-01-11 18:34

    I had this but it turned out to be an error in my settings.py which got shown up when I tried runserver instead. Fixed the error, and the command came back. Basically none of the management commands for any of the apps were there, so my INSTALLED_APPS must have been overwritten or never written in the first place. In my case, the import of the settings file was failing silently.

    0 讨论(0)
  • 2021-01-11 18:35

    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.

    0 讨论(0)
提交回复
热议问题