For QGIS 2.x, I used the batch file provided in the answer for this post in the OSGeo4W Shell to run standalone scripts: Problem with import qgis.core when writing a stand-alone PyQGIS script
The batch file for QGIS 2.18.17-ltr looks like this:
set PYTHONPATH=C:\Program Files\QGIS 2.18\apps\qgis-ltr\python
set PATH=C:\Program Files\QGIS 2.18\apps\qgis-ltr\bin;%PATH%
Now after installing QGIS 3.0, I would also like to run some standalone scripts. So I tweaked the above batch file:
set PYTHONPATH=C:\Program Files\QGIS 3.0\apps\qgis\python\
set PATH=C:\Program Files\QGIS 3.0\apps\qgis\bin;%PATH%
However, when I load this batch file into the shell and use from qgis.core import *
, I receive the following error message:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Program Files\QGIS 3.0\apps\qgis\python\qgis\__init__.py", line 26, in <module>
from builtins import zip
ImportError: No module named builtins
How can I set the paths correctly?
QGIS 3.0/bin/python-qgis.bat
. Running this sets the paths correctly and can execute the scripts. Please post your comment as an answer :)