Peewee(Python-Sqlite-ORM)-name错误:name';SqliteDatabase';没有定义
OS Linux Mint 18.3(但版本19也存在同样的问题)Peewee(Python-Sqlite-ORM)-name错误:name';SqliteDatabase';没有定义,python,sqlite,peewee,Python,Sqlite,Peewee,OS Linux Mint 18.3(但版本19也存在同样的问题) 已安装Python3和Sqlite3 在“pip/pip3”遇到很多麻烦之后,我设法安装了Peewee 我尝试使用python3 peewee.py运行以下示例脚本,但出现以下错误: 脚本(peewee.py) 错误 Traceback (most recent call last): File "peewee.py", line 3, in <module> from peewee import *
已安装Python3和Sqlite3 在“pip/pip3”遇到很多麻烦之后,我设法安装了Peewee 我尝试使用
python3 peewee.py
运行以下示例脚本,但出现以下错误:
脚本(peewee.py)
错误
Traceback (most recent call last):
File "peewee.py", line 3, in <module>
from peewee import *
File "/home/.../peewee.py", line 6, in <module>
db = SqliteDatabase("people.db")
NameError: name 'SqliteDatabase' is not defined
回溯(最近一次呼叫最后一次):
文件“peewee.py”,第3行,在
从peewee进口*
文件“/home/../peewee.py”,第6行,在
db=SqliteDatabase(“people.db”)
NameError:未定义名称“SqliteDatabase”
我已经对google/StackOverflow做了广泛的研究,但我无法解决这个问题。你能帮帮我吗?我尝试了一种不同的方法来解决这个问题。。。事实证明,这个问题与peewee无关,而是与python有关 我将脚本文件命名为peewee.py。 因此,由于peewee import*中脚本
的第一行,Python导入了我自己的脚本,而不是真正的peewee包,因此出现了错误
解决方案
将脚本文件重命名为其他文件。
(评论:……太可悲了……一个愚蠢的新手错误浪费了很多时间)
来源:
Traceback (most recent call last):
File "peewee.py", line 3, in <module>
from peewee import *
File "/home/.../peewee.py", line 6, in <module>
db = SqliteDatabase("people.db")
NameError: name 'SqliteDatabase' is not defined