I installed QGIS by using OsGeo4W64. I can use pyqgis PyQt5 version in PyCharm. However, when I write scripts in python console in QGIS, it does not accept. I looked the version of QGIS. It says developper version 2.99 and PyQt5.9.

When I write in python console:

from PyQt5.QtCore import *

I get this error:

Traceback (most recent call last):
  File "C:\OSGEO4~1\apps\Python36\lib\code.py", line 64, in runsource
    code = self.compile(source, filename, symbol)
  File "C:\OSGEO4~1\apps\Python36\lib\codeop.py", line 168, in __call__
    return _maybe_compile(self.compiler, source, filename, symbol)
  File "C:\OSGEO4~1\apps\Python36\lib\codeop.py", line 99, in _maybe_compile
    raise err1
  File "C:\OSGEO4~1\apps\Python36\lib\codeop.py", line 87, in _maybe_compile
    code1 = compiler(source + "\n", filename, symbol)
  File "C:\OSGEO4~1\apps\Python36\lib\codeop.py", line 133, in __call__
    codeob = compile(source, filename, symbol, self.flags, 1)
  File "<input>", line 1
    from PyQt5.QtCore import *

I found the solution.

I wrote the python console like that:

from PyQt.QtCore import *

and it works!

  • 1
    It changed again because in my case it works with: from PyQt5.QtCore import * and from PyQt5.QtGui import * – xunilk Nov 26 '17 at 23:28
  • Yes you are right! – Mustafa Uçar Nov 27 '17 at 13:00

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.