我遇到以下错误,不确定如何解决。我知道它与我的导入有关,但是我不确定要解决此问题需要做什么。
Traceback (most recent call last):
File "WebOutput.py", line 1, in <module>
import DatabaseInteractor
File "/Users/yaminhimani/Desktop/tweetybird/DatabaseInteractor.py", line 3, in <module>
import WebOutput
File "/Users/yaminhimani/Desktop/tweetybird/WebOutput.py", line 4, in <module>
db = DatabaseInteractor.DatabaseInteractor()
AttributeError: partially initialized module 'DatabaseInteractor' has no attribute 'DatabaseInteractor' (most likely due to a circular import)
WebOutput.py文件
import DatabaseInteractor
import nltk
db = DatabaseInteractor.DatabaseInteractor()
class WebOutput:
def __init__(self,text):
self.text= text
#self.hashtag = input("Enter Hashtag")
DataInteractor.py文件
import mysql.connector
import Tweet
import WebOutput
import re
class DatabaseInteractor:
def __init__(self):
# connects to the mysql server
# config settings should be changed based on where you are trying to connect (they are currently set for my local sql server)
config = {
}
答案 0 :(得分:0)
您要在WebOutput中导入DatabaseInteractor,然后要在DatabaseInteractor中导入WebOutput!我建议您将某物移动到另一个文件中,只需将其导入到您需要的文件中,或者以某种方式重新排列代码,就必须找出彼此不需要的地方!