Denny
Denny

Reputation: 57

Installing Python modules (rioxarray) for QGIS -> problems with dependencies

Installing rioxarray is a pain because of a dependency on gdal... Trying to install it for QGIS's python version is even more frustrating. I need to install the module for QGIS because I want to build a QGIS plugin using this module.

Trying to install it (python -m pip install rioxarray) via the OSGeo4W-shell gives the following error:

 >ERROR: Command errored out with exit status 1:
   command: 'C:\OSGEO4~1\apps\Python37\python.exe' 'C:\OSGEO4~1\apps\Python37\lib\site-packages\pip\_vendor\pep517\_in_process.py' get_requires_for_build_wheel 'C:\Users\Asus\AppData\Local\Temp\tmpsnn_l_xj'
       cwd: C:\Users\Asus\AppData\Local\Temp\pip-install-alfs_4ee\rasterio
  Complete output (2 lines):
  INFO:root:Building on Windows requires extra options to setup.py to locate needed GDAL files. More information is available in the README.
  ERROR: A GDAL API version must be specified. Provide a path to gdal-config using a GDAL_CONFIG environment variable or use a GDAL_VERSION environment variable.
  ----------------------------------------
>ERROR: Command errored out with exit status 1: 'C:\OSGEO4~1\apps\Python37\python.exe' 'C:\OSGEO4~1\apps\Python37\lib\site-packages\pip\_vendor\pep517\_in_process.py' get_requires_for_build_wheel 'C:\Users\Asus\AppData\Local\Temp\tmpsnn_l_xj' Check the logs for full command output.

I'm not quite sure how to provide a path (and which path) to the gdal-config to overcome this problem. What makes it even more confusing is the fact that my computer has 4 different versions of python installed, which are used by different programs and I'm not sure how to tell pip to choose the right version of python, which is used by QGIS. Especially because my computer says (by py -0) that QGIS's Python version (3.7) does not exist - but it does exist.

Thank you very much for your help :-)

Upvotes: 2

Views: 830

Answers (2)

Heang Sok
Heang Sok

Reputation: 140

Alternative way: Local installation:

\\ first:
git clone [email protected]:corteva/rioxarray.git

\\ cd to that directory
cd rioxarray

\\ install locally
python setup.py install

Hope it will work for you.

Upvotes: 0

PerteTotale
PerteTotale

Reputation: 114

win cmd>where python produces path(s) of active python installation(s)

QGIS's python version might have older module versions than your local installed python environment. These 2 envirs are separated for reasons of dependency problems.

I seem to remember that

  • you can set/correct the path to GDAL_CONFIG environment variable in the qgis config ui. OR
  • The full QGIS-OSGeo4W -installer should take care of it during install. Smaller update install pkgs sometimes miss setting the path appar.

Btw: xarray is not in my qgis env pip list, so try installing that first in yr qgis env via OSGeo4W-shell., before riox.

Added: Building (rasterio) on Windows? Stop. Better approach is first to try installing the needed whls from https://www.lfd.uci.edu/~gohlke/pythonlibs/#gdal #rasterio in the QGIS python env.

Upvotes: 1

Related Questions