• Register
2 votes


I am new in python programming an I am using Jet Brains Pycharm IDE.
In pycharm I have program organized like:

But there is an warning that always appear:

Cannot find reference 'Add' in __init__.py

Why is this warning always appear please help

10 7 2
6,060 points

Please log in or register to answer this question.

2 Answers

2 votes


Looks like this issue will pop up again if one use a remote environment in PyCharm, because PyCharm somehow forget to sync these *.pyi files to the local remote storage.
Solution: Manually mapping the local remote storage to the remote path, then sync *.pyifiles to local would solve these problem.

Plz spread this tip so nobody suffer from these annoying falsify inspection warning again

PyCharm has its share of small bugs like this, but in my opinion its benefits far outweigh its drawbacks. If you'd like to try another good IDE, there's also Spyder/Spyderlib.

You can locate the path to local storage at the Project View -> External Libraries -> Your Environment -> Remote Libraries, then right click and choose "Copy Path"

Please look out if there is any update in you IDE.

If this helps you let me know.



11 6 4
34,950 points
0 votes


I guess this is a bug in pycharm. PyCharm exhibits to be expecting the referenced module to be added in an __all__ = [] statement.

For precise coding etiquette, must you include the __all__ statement from your modules? this is really the question we hear young Spock answering while he was being tested, to which he responded: "It is morally praiseworthy however not morally obligatory."

To get around it, you can easily disable that  (highly helpfulful) inspection globally, or inhibit it for the earmarked function or statement.

To do so:

  • Place the caret over the erroring text ('choice', from your example above)

  • Educate the intention menu (alt-enter by default, mine is set to alt-backspace)

  • Press the right arrow to open the submenu, and choose the relevant action

PyCharm has its share of small bugs like this, however in my view its benefits far outweigh its drawbacks. In case you'd like to attempt another good IDE, there's also Spyder/Spyderlib.

I know this is quite a bit after you asked your question, however I hope this helps.

Edited: Generally, I conceived that this was earmarked to checking __all__, however it seems like it's the more general 'Unresolved References' check, which can be very helpful. It's likely best to employ statement-level disabling of the feature, either by employing the menu as mentioned above, or by earmarked # noinspection PyUnresolvedReferences on the line preceding the statement.

You must first take a look at this. This interprets what occurs at the time you import a package. For convenience:

The import statement conduct the following convention: in case a package’s __init__.py code defines a list named __all__, it is taken to be the list of module names that must be imported when from package import * is encountered. It is up to the package author to keep this list up-to-date at the time a fresh version of the package is released. Package authors may also fix not to support it, in case they don’t see a use for importing * from their package.

Hence PyCharm respects this by displaying a warning message, so that the author can decide which of the modules get imported when * from the package is imported. Thus this appears to be helpful property of PyCharm (and in no way can it be named a bug, I suppose). You can simply remove this warning by including the names of the modules to be imported at the time your package is imported in the __all__ variable which is list, like this


from . import MyModule1, MyModule2, MyModule3
__all__ = [MyModule1, MyModule2, MyModule3]

Afterwards you include this, you can ctrl+click on these module names used in any other part of your project to directly jump to the declaration, which I often find very helpful.

10 6 4
31,120 points

Related questions

0 votes
1 answer 7 views
Problem: On the Internet, I tried to find a solution, but could not find any valuable information.
asked Apr 13 zayed1 61.8k points
0 votes
1 answer 5 views
Problem: I'm having problems during my learning as I mentioned in my question above, I try to find on web search but I can't get proper information, can you help me to continue my project?
asked Mar 21 rubelkhan 20.4k points
0 votes
1 answer 21 views
Problem: What is __init__.py for in a Python source directory?But just it contains an example, more information, and an explanation of namespace packages, the kind of packages without __init__.py.
asked Feb 21 Mashhoodch 13k points
0 votes
1 answer 12 views
What is __init__.py for? anyone can answer ?
asked Mar 12 sadi1982 36.3k points
0 votes
1 answer 35 views
Problem: What is the purpose of __ init __? Is __ init __ necessary in Python? What does __ init __ return? Whenever object oriented programming is done in Python, we mostly come across __init__ method which we usually don’t fully understand. This article explains the main concept of __init__ but before understanding the __init__ some prerequisites are required.
asked Jan 6 Mashhoodch 13k points
0 votes
1 answer 43 views
373 I'm learning the Python programming language and I've came across something I don't fully understand. In a method like: def method(self, blah): def __init__(?): .... .... What does self do? What is it meant to be? Is it mandatory? What does the __init__ method do? Why is it necessary? (etc.) I think they might be OOP constructs, but I don't know very much.
asked Oct 25, 2020 psandprop 2.4k points
1 vote
1 answer 27 views
Problem: I have a program that is organized like: Sources |--__init__.py |--Additions |--__init__.py |--Add.py |--Collaboration |--__init__.py |--Colab.py |--Views |--__init__.py |--views.py |--Model |--__init__.py |--Models.py Can anybody explain me the “__init__.py” that is in every file?
asked May 4, 2020 samhaz 5k points
1 vote
1 answer 5 views
Problem: I am getting this error : TypeError: module.__init__() takes at most 2 arguments (3 given) Here’s my code : import Object class Visitor(Object): pass instance = Visitor() # this line throws the exception How can I solve this error ?
asked 3 days ago Raj Tyagi 14.9k points
1 vote
1 answer 5 views
Problem: I need a help , How I can fix this : python def __init__
asked Mar 30 MUHAMMAD MUNEEB 83k points
0 votes
1 answer 5 views
Problem: I used Google to try to find a solution on the web of the above question, But I got no useful hints. Can I get Pointer information about my problem with this?
asked Mar 21 shamimkhan 15.1k points