南:未知命令“迁移" [英] South: Unknown command 'migrate'

查看:26
本文介绍了南:未知命令“迁移"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我心狠手辣

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

我将代码从 github 提取到新计算机上.此代码经过测试,正在其他计算机上运行.整个代码运行良好,除了我无法运行迁移!

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!

安装我的虚拟环境并运行 pip install -r requirements.txt.它安装了所有东西,包括南方.我可以通过运行来检查

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'

但是,当我运行 manage.py help 时,migrateschemamigration 命令没有出现在列表中.

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

我仔细检查了我的 settings.py 文件是否在 INSTALLED_APPS 下列出了south"(拉取后我没有更改此文件).

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

我尝试了 pip uninstall south 然后再次运行 pip install -r requirements.txt,但仍然遇到同样的错误.

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

非常感谢任何帮助!

推荐答案

成功导入包对于Django管理命令是不够的.Python 可以很容易地从一个压缩的鸡蛋中导入一个包,但 Django 需要一个普通的未压缩文件.

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. 管理命令必须以文件形式存在于普通目录path..to..south/management/commands(未压缩)中.
  2. 尝试手动查找并删除 south 的旧安装.一个常见的问题是,某个软件包的一个版本已通过 easy_install(压缩)或通过python setup.py install"手动安装,但 pip 没有卸载它并第二次安装它.
  3. 在 python 路径中仅使用绝对目录.如果可能,请不要在环境中或通过自定义的 manage 或 settings.py 更改安装程序和运行 Django 之间的 python 路径.一些 manage.py 或 settings.py 使用的 python 路径与包安装程序使用的路径不同,例如添加 "."或.."在其他目录之前.您的项目中的 ... 中不应有其他 south 目录.
  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.

建议 1 是 Django 的绝对要求.即使我使用多个版本以某种方式使用多个版本的 Python、Django 等测试我的应用程序,其他两个也很有帮助.

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.

主要需求调查示例:

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

这篇关于南:未知命令“迁移"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆