由于AttributeError,我无法使用south同步数据库

时间:2014-01-10 06:02:15

标签: python database django ubuntu django-south

尝试迁移后出现solve错误,现在我遇到了south包的另一个问题。

正在运行manage.py syncdbmanage.py schemamigration MyApp --initial我得到this

AttributeError: 'module' object has no attribute '__file__'

This post提到问题已通过新版本(0.8.4)解决,但不适合我,因为我有最新版本。

我正在使用python3.3运行虚拟环境 - 任何线索?


如果您没有看到该链接或者不想打开它,那么这里是纯文本的完整堆栈跟踪:

Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/home/hogar/Development/python/django/enviroments/share_this/lib/python3.3/site-packages/django/core/management/__init__.py", line 399, in execute_from_command_line
    utility.execute()
  File "/home/hogar/Development/python/django/enviroments/share_this/lib/python3.3/site-packages/django/core/management/__init__.py", line 392, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/hogar/Development/python/django/enviroments/share_this/lib/python3.3/site-packages/django/core/management/base.py", line 242, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/home/hogar/Development/python/django/enviroments/share_this/lib/python3.3/site-packages/django/core/management/base.py", line 285, in execute
    output = self.handle(*args, **options)
  File "/home/hogar/Development/python/django/enviroments/share_this/lib/python3.3/site-packages/south/management/commands/schemamigration.py", line 87, in handle
    migrations = Migrations(app, force_creation=True, verbose_creation=int(verbosity) > 0)
  File "/home/hogar/Development/python/django/enviroments/share_this/lib/python3.3/site-packages/south/migration/base.py", line 64, in __call__
    self.instances[app_label] = super(MigrationsMetaclass, self).__call__(app_label_to_app_module(app_label), **kwds)
  File "/home/hogar/Development/python/django/enviroments/share_this/lib/python3.3/site-packages/south/migration/base.py", line 90, in __init__
    self.set_application(application, force_creation, verbose_creation)
  File "/home/hogar/Development/python/django/enviroments/share_this/lib/python3.3/site-packages/south/migration/base.py", line 163, in set_application
    self._load_migrations_module(application.migrations)
  File "/home/hogar/Development/python/django/enviroments/share_this/lib/python3.3/site-packages/south/migration/base.py", line 170, in _load_migrations_module
    dirname = self.migrations_dir()
  File "/home/hogar/Development/python/django/enviroments/share_this/lib/python3.3/site-packages/south/migration/base.py", line 132, in migrations_dir
    return os.path.dirname(module.__file__)
AttributeError: 'module' object has no attribute '__file__'

3 个答案:

答案 0 :(得分:4)

为了完整起见,我突出了@rara_tiru的评论答案作为答案,因为它也是我的问题:我的应用程序中还有一个迁移文件夹,当删除迁移文件夹时,它有效。使用Python 3.3 / South 1.0 / Django 1.6.5。

答案 1 :(得分:1)

问题是我在整个项目中使用python3.3但是使用pyhon2.7输入了初始python manage.py syncdb命令,这将在以后给我几个问题。

在从头开始生成项目并在the output of manage.py syncdb中查看错误后,我注意到了这一点。

然后我删除了postgre-sql中的所有信息,并在source bin/activate之后运行python3 manage.py syncdb

答案 2 :(得分:1)

至少在Django 1.5中如果你有空的“迁移”目录,也会发生AttributeError: 'module' object has no attribute '__file__'错误。