3

I am trying to get the PyQGIS working with the Spyder installed as part of Anaconda.

I first get the path to PyQGIS and dependent packages from QGIS console, typing:

import sys
sys.path

After that I add the path outputted by this command in sys.path within Spyder:

sys.path.extend(['my/path/list']). 

After this, I can import qgis.core, but while importing qgis.gui, it gives and error saying

"RuntimeError: qgis._gui cannot import type '����' from PyQt5.QtCore"

From within the QGIS console everything works fine.

The spefications of my system are:

  • Operating system: Ubuntu (18.04 bionic) on Windows 10. For GUI I use VcXsrv X Server.
  • Python version: 3.7.2
  • PyQt5 version in Spyder: 5.9.2
  • QGIS version: 3.6

I thought it is, maybe, related to the version of PyQt5 that I use in Spyder. In Spyder it is 5.9.2, whereas in QGIS it is 5.10.1. However, installing newer version (5.12.1) of PyQt5 the problem did not solve, instead qgis.core also stopped importing. When I try to import qgis.core, python interpreter crashes saying "Segmentation fault (core dumped)".

What could be the problem here?

1

Not sure if you still have this issue, but just in case it helps someone:

I had a similar issue with Ubuntu Studio 18.04, trying to make QGIS 3.4 and 3.10 work. I am currently using the ubuntugis PPA and using the corresponding version from the QGIS repositories.

I kept having the same runtime error, and also the following one after playing around with installing different PyQt5 version with pip3:

Traceback (most recent call last):
  File "", line 1, in 
  File "/usr/lib/python3/dist-packages/qgis/core/__init__.py", line 25, in 
    from qgis._core import *
ValueError: PyCapsule_GetPointer called with incorrect name

I ended up uninstalling the modules with pip3 so QGIS would revert to using what I assume to be my system's ones:

pip3 uninstall PyQt5-sip
pip3 uninstall PyQt5

This page put me on the right track: https://tutel.me/c/gis/questions/306595/qgis+34+couldn39t+load+sip+module+python+support+will+be+disabled+on+windows+10

I also talked about this problem on the QGIS issue tracker: https://github.com/qgis/QGIS/issues/34317

| improve this answer | |

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.