Linked Questions
259 votes
20 answers
971k views
AttributeError: 'module' object has no attribute [duplicate]
I have two python modules: a.py import b def hello(): print "hello" print "a.py" print hello() print b.hi() b.py import a def hi(): print "hi" When I run a.py, I get: AttributeError: '...
220 votes
3 answers
238k views
How to avoid circular imports in Python? [duplicate]
I know the issue of circular imports in python has come up many times before and I have read these discussions. The comment that is made repeatedly in these discussions is that a circular import is a ...
97 votes
7 answers
97k views
Circular import dependency in Python [duplicate]
Let's say I have the following directory structure: a\ __init__.py b\ __init__.py c\ __init__.py c_file.py d\ __init__.py ...
55 votes
5 answers
65k views
Django cannot import name x [duplicate]
I got an error I don't understand ! cannot import name Item In my model, I have items. These items are required for actions. But some of these items have an effect on actions : items from django....
21 votes
1 answer
48k views
Error using matplotlib in PyCharm: has no attribute 'FigureCanvas' [duplicate]
I have this code: import matplotlib.pyplot as p1lt #define data x = [1, 2, 3, 4, 5, 6] y = [3, 7, 14, 19, 15, 11] #create line plot p1lt.plot(x, y) #show line plot p1lt.show() I get an error that ...
3 votes
3 answers
22k views
cannot import name 'db' from partially initialized module 'models' (most likely due to a circular import) [duplicate]
I am able to run my flask tests utilizing the following command python -m unittest discover -p testing.py but when I try to run python app.py runserver it shows me the following error message: ...
3 votes
2 answers
34k views
Import Error: cannot import name 'tqdm' from 'tqdm' [duplicate]
Trying to execute the following code to check how the progress bar works with the tqdm module but receiving an "ImportError: cannot import name 'tqdm' from 'tqdm' " Code from tqdm import ...
-4 votes
2 answers
9k views
Cannot import variable from script in Python [duplicate]
Python newbie here. Let's say I have two Python scripts main.py and lib.py. There is a variable (not a function) in lib.py that I want to use in main.py. I imported lib.py in main.py and called lib....
0 votes
1 answer
8k views
How to fix 'AttributeError: partially initialized module 'SendEmail' has no attribute 'send_email' (most likely due to a circular import)' [duplicate]
So I am creating a Gmail Sender app using Tkinter and I have a function called send_email and it is inside the SendEmail.py. But every time I run the code it gives me this error: Exception in Tkinter ...
0 votes
1 answer
2k views
Storing keystrokes into text file [duplicate]
I have taken a piece of code from https://pynput.readthedocs.io/en/latest/keyboard.html and modified it so that it stores keystrokes into a text file. However, I get the error message in the output: ...
-1 votes
1 answer
3k views
ImportError: cannot import name <...> (most likely due to a circular import) [duplicate]
I have an issue with relative imports in python. (I really can't do these imports the other way...) Structure of my project is similar to this: app ├───schemas └───__init__.py └───...
1 vote
1 answer
558 views
ImportError: cannot import name MainClass [duplicate]
society. I'm trying to understand the OOP programming and I'm facing some issues and asking for help. Here the example: I'm trying to create all objects under one class and then I want to inherit ...
0 votes
0 answers
264 views
cannot import function python structure [duplicate]
I have the folllowing folder structure on my python project: As I understand from this link that explains a python file structure my whole python project will run from the bin/rain_it.py. The code ...
1 vote
0 answers
242 views
Python cannot import class [duplicate]
My problem is: I am unable to import the model's Role class (Or anything from the models for that matter). I have a simple file structure in my Flask app (theres more but the problem is here): myapp ...
0 votes
1 answer
223 views
ImportError: cannot import name 'idkom' from partially initialized module 'idkom' (most likely due to a circular import) [duplicate]
I have a problem that the program throws this error: ImportError: cannot import name 'idkom' from partially initialized module 'idkom' (most likely due to a circular import) (d: \ Python \ Crystalia \ ...