peewee:对象没有属性_meta

seb*_*t26 3 python attributeerror python-3.x peewee

我在使用Python 3.3 32位的Windows上工作.我已经安装了peewee并想尝试它的一些功能.我已经开始使用Peewee Quickstart(http://peewee.readthedocs.org/en/latest/peewee/quickstart.html).

我的代码看起来像这样:

from peewee import *

db = SqliteDatabase('people.db')

class Person(Model):
    name = CharField()
    birthday = DateField()
    is_relative = BooleanField()

    class Meta:
            database = db

class Pet(Model):
    owner = ForeignKeyField(Person, related_name = "pets")
    name = CharField()
    animal_type = CharField()

    class Meta:
            database = db

Person.create_table()
Pet.create_table()
Run Code Online (Sandbox Code Playgroud)

我收到一个错误:

File "<stdin>", line 1, in <module>
File "<string>", line 21, in <module>
File "C:\Python33\lib\site-packages\peewee.py", line 2094, in create_table
db = cls._meta.database
AttributeError: type object 'Person' has no attribute '_meta'
Run Code Online (Sandbox Code Playgroud)

我安装的小便有问题吗?我该如何解决这个问题?

Mar*_*ers 5

Peewee 兼容Python 3; 它目前仅适用于Python 2.

你看到的错误就是这样的结果; 在Model类定义使用Python 2技术,其已经改变为Python 3元类.

更新:版本2.1,发布于2013-04-02,增加了Python 3的兼容性.该软件包现在支持Python 2.6,2.7和3.2及更高版本.