Bug report #20907
Cannot "from qgis.core import *" from Python script
Status: | Closed | ||
---|---|---|---|
Priority: | Normal | ||
Assignee: | - | ||
Category: | Python bindings / sipify | ||
Affected QGIS version: | 3.4.3 | Regression?: | No |
Operating System: | Windows 10 Home Edition 64-bit | Easy fix?: | No |
Pull Request or Patch supplied: | No | Resolution: | invalid |
Crashes QGIS or corrupts data: | No | Copied to github as #: | 28726 |
Description
While attempting to create a custom Python script for QGIS v3.4.3 (Madeira), I encountered the following Python error after running this command:
from qgis.core import *
Stack trace:
Traceback (most recent call last): File "<pyshell#0>", line 1, in <module> from qgis.core import * File "C:\Program Files\QGIS 3.4\apps\qgis\python\qgis\__init__.py", line 80, in <module> import qgis.gui File "C:\Program Files\QGIS 3.4\apps\qgis\python\qgis\gui\__init__.py", line 27, in <module> from qgis._gui import * ValueError: PyCapsule_GetPointer called with incorrect name
Note: This particular trace was generated by IDLE (thus "<pyshell#0>" as the original file name).
Other instances of a similar error (involving `PyCapsule_GetPointer`) have been reported with PyQt in its own bug tracker.
Oddly enough, when this same command is run in the QGIS Python console, no errors are generated.
Also, this error came after the same import command was unable to find the PyQt5 module. This was resolved by `pip install`ing PyQt5, which I initially assumed that QGIS had already done.
History
#1 Updated by Jürgen Fischer almost 6 years ago
- Resolution set to invalid
- Status changed from Open to Closed
You have to setup the environment (eg. by running "call py3_env.bat" and "call qt5_env.bat"; see also qgis.bat
/ python-qgis.bat
).