Search code examples
pythonpycharmkivykivy-language

I keep getting the "Unresolved reference" error when I use kivy properties in PyCharm


I am new to coding and do not understand why I keep get this error when I use kivy properties

PyCharm Community 2021.1.3

Kivy 2.0.0

from kivy.app import App
from kivy.uix.widget import Widget
from kivy.properties import NumericProperty, ReferenceListProperty
from kivy.vector import Vector


Solution

  • There are many solutions to this, some more convenient than others, and they don't always work.

    File > Settings > Project > Project Interpreter 
    > Select "No interpreter" in the "Project interpreter" list 
    > Apply > Set your python interpreter again > Click Apply
    

    Here's all you can try, going from 'quick' to 'annoying':

    Do File -> Invalidate Caches / Restart and restart PyCharm. You could also do this after any of the below methods, just to be sure. First, check which interpreter you're running: Run -> Edit Configurations -> Configuration -> Python Interpreter.

    Refresh the paths of your interpreter: File -> Settings Project: [name] -> Project Interpreter -> 'Project Interpreter': Gear icon -> More... Click the 'Show paths' button (bottom one) Click the 'Refresh' button (bottom one)

    Remove the interpreter and add it again: File -> Settings Project: [name] -> Project Interpreter -> 'Project Interpreter': Gear icon -> More... Click the 'Remove' button Click the 'Add' button and re-add your interpeter

    Delete your project preferences Delete your project's .idea folder Close and re-open PyCharm Open your project from scratch

    Delete your PyCharm user preferences (but back them up first). ~/.PyCharm50 on Mac %homepath%/.PyCharm50 on Windows Switch to another interpreter, then back again to the one you want. Create a new virtual environment, and switch to that environments' interpreter. Switch to another interpreter altogether, don't switch back.

    If you are using Docker, take note:

    Make sure you are using pip3 not pip, especially with remote docker and docker-compose interpreters. Avoid influencing PYTHONPATH. More info here: https://intellij-support.jetbrains.com/hc/en-us/community/posts/115000058690-Module-not-found-in-PyCharm-but-externally-in-Python