【问题标题】:Error in migration of django app using celery使用 celery 迁移 django 应用程序时出错
【发布时间】:2015-04-30 06:28:17
【问题描述】:

我在我的 django 应用程序中使用 celery。我像往常一样设置了芹菜。但是,当我尝试迁移时,它显示错误:

Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/local/lib/python3.4/dist-packages/django/core/management/__init__.py", line 385, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python3.4/dist-packages/django/core/management/__init__.py", line 377, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/lib/python3.4/dist-packages/django/core/management/base.py", line 288, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/usr/local/lib/python3.4/dist-packages/django/core/management/base.py", line 338, in execute
    output = self.handle(*args, **options)
  File "/usr/local/lib/python3.4/dist-packages/django/core/management/commands/makemigrations.py", line 111, in handle
    convert_apps=app_labels or None,
  File "/usr/local/lib/python3.4/dist-packages/django/db/migrations/autodetector.py", line 42, in changes
    changes = self._detect_changes(convert_apps, graph)
  File "/usr/local/lib/python3.4/dist-packages/django/db/migrations/autodetector.py", line 109, in _detect_changes
    self.old_apps = self.from_state.render(ignore_swappable=True)
  File "/usr/local/lib/python3.4/dist-packages/django/db/migrations/state.py", line 57, in render
    self.apps = Apps([AppConfigStub(label) for label in sorted(self.real_apps + list(app_labels))])
  File "/usr/local/lib/python3.4/dist-packages/django/apps/registry.py", line 56, in __init__
    self.populate(installed_apps)
  File "/usr/local/lib/python3.4/dist-packages/django/apps/registry.py", line 89, in populate
    "duplicates: %s" % app_config.label)
django.core.exceptions.ImproperlyConfigured: Application labels aren't unique, duplicates: djcelery
Operations to perform:
  Synchronize unmigrated apps: djcelery
  Apply all migrations: auth, contenttypes, admin, djcelery, sessions
Synchronizing apps without migrations:
  Creating tables...
  Installing custom SQL...
  Installing indexes...
Running migrations:
  Applying djcelery.0001_initial...Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/local/lib/python3.4/dist-packages/django/core/management/__init__.py", line 385, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python3.4/dist-packages/django/core/management/__init__.py", line 377, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/lib/python3.4/dist-packages/django/core/management/base.py", line 288, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/usr/local/lib/python3.4/dist-packages/django/core/management/base.py", line 338, in execute
    output = self.handle(*args, **options)
  File "/usr/local/lib/python3.4/dist-packages/django/core/management/commands/migrate.py", line 161, in handle
    executor.migrate(targets, plan, fake=options.get("fake", False))
  File "/usr/local/lib/python3.4/dist-packages/django/db/migrations/executor.py", line 68, in migrate
    self.apply_migration(migration, fake=fake)
  File "/usr/local/lib/python3.4/dist-packages/django/db/migrations/executor.py", line 96, in apply_migration
    if self.detect_soft_applied(migration):
  File "/usr/local/lib/python3.4/dist-packages/django/db/migrations/executor.py", line 140, in detect_soft_applied
    apps = project_state.render()
  File "/usr/local/lib/python3.4/dist-packages/django/db/migrations/state.py", line 57, in render
    self.apps = Apps([AppConfigStub(label) for label in sorted(self.real_apps + list(app_labels))])
  File "/usr/local/lib/python3.4/dist-packages/django/apps/registry.py", line 56, in __init__
    self.populate(installed_apps)
  File "/usr/local/lib/python3.4/dist-packages/django/apps/registry.py", line 89, in populate
    "duplicates: %s" % app_config.label)
django.core.exceptions.ImproperlyConfigured: Application labels aren't unique, duplicates: djcelery

我正在使用 django 版本 1.7.5 和 celery 版本 3.1.17。在示例代码中,settings.py 中的应用列表中只添加了 djcelery 应用。

【问题讨论】:

  • 但我没有将任何应用程序添加到项目中。使用 pip 安装 Celery,并将 djcelery 添加到 installed_app 列表中。因此,没有应用程序包冲突。
  • 您找到解决方案了吗?我有同样的问题

标签: python django migration celery


【解决方案1】:

我认为我遇到了同样的问题。我试图在已安装的应用程序甚至其他包中名为 djcelery 的模块上找到重复的名称。没有找到任何帮助。就我而言,该应用程序在某些机器上运行良好,但在其他机器上却失败了。我什至可以让它运行,但迁移一直失败。

解决我的问题的方法是重新安装我所有的 pip 包。假设您在文件 requirements.txt 中列出了所有包:

pip uninstall -r requirements.txt

然后

pip install -r requirements.txt

我认为这个问题可能是由死 pyc 或糟糕的依赖链引起的。我还发现 mysql for python 部分由 pip 安装,部分由 apt-get 安装(在 Ubuntu 上运行)存在问题。你可以检查这个运行你的命令,如:

python -m pdb manage.py migrate

pdb 报告的错误与连接错误有关。如果没有 pdb,我会收到与您相同的信息。

在 Ubuntu 上使用 Python 2.7.6、pip 6.1.1、django 1.7、celery 3.1.8、django-celery-3.1.16 进行测试。

【讨论】:

    【解决方案2】:

    问题肯定源于djcelery 出现在unmigrated 和migrated 应用程序中。从我所见,这通常是在同一个应用程序中同时具有south 和django 样式迁移的症状。无论如何,djcelery 的迁移目录可能有问题。

    【讨论】:

      猜你喜欢
      • 2010-10-27
      • 2019-04-17
      • 2016-04-10
      • 1970-01-01
      • 2016-04-14
      • 1970-01-01
      • 1970-01-01
      • 2015-04-08
      • 1970-01-01
      相关资源
      最近更新 更多