In my code I'm using the classes QgsProject() and QgsVectorLayer(). However PyCharm gives me the following error:

Unresolved reference 'QgsProject' Inspection info: This inspection detects names that should resolve but don't.

The Project Interpreter is "Python3.7(firstplugin) C:\OSGeo4W64\bin\pyton-qgis.bat" which should be correct.

Any ideas how to solve this problem? I think I need to import something but I can't find what

  • Show us the current import lines in your code. – user2856 Aug 31 '19 at 22:45

Ensure you have imported QgsProject and QgsVectorLayer:

from qgis.core import (QgsProject, QgsVectorLayer)
  • yes, that was missing. Thank you :) – DGIS Sep 3 '19 at 6:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.