-1

I am having the error below and I am not sure how to fix it. I know it has something to do with my imports but I am not sure what needs to be done in order to fix this issue.

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 file

import DatabaseInteractor
import nltk

db = DatabaseInteractor.DatabaseInteractor()

class WebOutput:

  def __init__(self,text):
    self.text= text
    #self.hashtag = input("Enter Hashtag")

DataInteractor.py file

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 = {

            }
Yamin Himani
  • 77
  • 1
  • 9
  • 1
    The error is clear, you have circular imports, meaning in file webOutput you import dataInteractor and viceversa, you can't do this. You will have to move the code around to avoid circular imports. – Carlos Gonzalez Jun 18 '20 at 21:10

1 Answers1

0

You are importing DatabaseInteractor in WebOutput, then you are importing WebOutput in DatabaseInteractor!! I suggest you to move something to another file, just import it in both for what you need or rearrange the code in some way you have to figure out not to need one each other!!