I am trying to use QGIS in stand-alone python scripts (windows 10, python 3.6.6).
After the following steps...
create new conda environment (geospatial)
install the qgis conda-forge package through
conda install -c conda-forge qgis
as per conda-forge page (https://anaconda.org/conda-forge/qgis)run anaconda prompt and activate the geospatial environment
I ran python and tried to import qgis.core
. And I got the ModuleNotFoundError
error.
(geospatial) C:\Users\vince>python
Python 3.6.6 | packaged by conda-forge | (default, Jul 26 2018, 11:48:23) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import qgis.core
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'qgis'
From reading other resources, it seems PYTHONPATH and PATH need to be set, but after setting those (see below), I still get an error on import qgis.core
, this time an "ImportError: DLL load failed" error.
See the following anaconda prompt output:
(geospatial) C:\Users\vince>set PYTHONPATH=C:\Anaconda3\envs\geospatial\Library\python
(geospatial) C:\Users\vince>set PATH=C:\Anaconda3\envs\geospatial\Library\bin;%PATH%
(geospatial) C:\Users\vince>python
Python 3.6.6 | packaged by conda-forge | (default, Jul 26 2018, 11:48:23) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import qgis.core
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Anaconda3\envs\geospatial\Library\python\qgis\__init__.py", line 72, in <module>
from qgis.core import QgsFeature, QgsGeometry
File "C:\Anaconda3\envs\geospatial\Library\python\qgis\core\__init__.py", line 34, in <module>
from qgis._core import *
ImportError: DLL load failed: The specified module could not be found.
The (Python) paths I set above were "derived" from similar paths I found when one wants to use QGIS API by installing "osgeo4w. So, the main question: When using the Conda-Forge QGIS package, what are the required PYTHONPATHs and PATHs to be set; and/or what other configuration is needed to get the conda-forge QGIS package going?