I am having problems with Intelij IDEA (community edition 2019.3.3 with the latest updates). When I ty to import a class from a different .py file that I have made, it is red underlined and says "cannot find reference". The code still works fine but it is really annoying it doesnt give me options when I start typing .lives or .name etc
I have tried invalidate caches / restart but after it finishes indexing the problem is back, how could I sort this?


class Player:
def __init__(self, name):
self.name = name
self._lives = 3
self._level = 1
self._score = 0
Main
from player import Player
kev = Player("Kevin")
print(kev.name)
Solution: mark the 'Game' directory as a sources root (right-click on the folder > Mark Directory as > Sources Root). It should be colored blue.
More on content roots in IDEA: https://jetbrains.com/help/idea/content-roots.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With