Skip to content

Some GDAL Functions not working via QGIS interface 3.4.14 Win10 #33386

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
mattenvsys opened this issue Dec 13, 2019 · 13 comments
Closed

Some GDAL Functions not working via QGIS interface 3.4.14 Win10 #33386

mattenvsys opened this issue Dec 13, 2019 · 13 comments
Assignees
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! High Priority Processing Relating to QGIS Processing framework or individual Processing algorithms Regression Something which used to work, but doesn't anymore

Comments

@mattenvsys
Copy link

mattenvsys commented Dec 13, 2019

Hi, certain GDAL tools are not working via QGIS Desktop 3.4.14 on Windows 10

For instance, GDAL Polygonise and GDAL Merge do not work

I receive the errors:

C:\PROGRA~1\QGIS3~1.4\bin\python3.exe: No module named gdal_merge
C:\PROGRA~1\QGIS3~1.4\bin\python3.exe: No module named gdal_polygonize

It is effecting all PCs in the office running this version and is reproducible on all raster datasets we have attempted to run.

  • Click Raster on the top tool bar
  • Select Conversion
  • Click Polygonise (Raster to Vector)
  • Set the parameters
  • Click run

Tool fails instantly

Believe it is something to do with the way QGIS is trying to call/run the command. Here's the initial part of the console call QGIS creates:

python3 -m gdal_polygonize 

Other GDAL tools, susch as GDAL Raster Calculator, work with no issues. Here is and example of the console call for calc:

gdal_calc --calc

QGIS and OS versions

QGIS version 3.4.14-Madeira
QGIS code revision
QGIS code revision
Compiled against Qt 5.11.2
Running against Qt 5.11.2
Compiled against GDAL/OGR 2.4.3
Running against GDAL/OGR 2.4.3
Compiled against GEOS 3.8.0-CAPI-1.13.1
Running against GEOS 3.8.0-CAPI-1.13.1
PostgreSQL Client Version 11.5
SpatiaLite Version 4.3.0
QWT Version 6.1.3
QScintilla2 Version 2.10.8
Compiled against PROJ 5.2.0
Running against PROJ Rel. 5.2.0, September 15th, 2018
Windows 10 Pro

@mattenvsys mattenvsys added the Bug Either a bug report, or a bug fix. Let's hope for the latter! label Dec 13, 2019
@agiudiceandrea
Copy link
Member

Same issue reported on the QGIS-User ML from another user
https://lists.osgeo.org/pipermail/qgis-user/2019-December/044443.html

and another one on StackExchange:
https://gis.stackexchange.com/questions/344713/qgis-3-python-doesnt-find-gdal-module

@alexbruy alexbruy added Build/Install Related to compiling or installing QGIS and removed Build/Install Related to compiling or installing QGIS labels Dec 14, 2019
@agiudiceandrea
Copy link
Member

It seems the PYTHONPATH environmental variable is not properly set.
It should be set to the path of the folder where there is gdal_polygonize.py (and the other gdal_*.py python scripts): on Windows with a standalone QGIS 3.4 installation it could be e.g. C:\PROGRA~1\QGIS3~1.4\apps\Python37\Scripts

@gioman gioman added Regression Something which used to work, but doesn't anymore High Priority labels Dec 15, 2019
@gioman
Copy link
Contributor

gioman commented Dec 15, 2019

There is something wrong with the most recent installers,
for example:

QGIS-OSGeo4W-3.4.13-2-Setup-x86_64.exe 11-Nov-2019 16:37 455M
does not show any issue

while

QGIS-OSGeo4W-3.4.13-3-Setup-x86_64.exe 05-Dec-2019 22:06 452M
(as also QGIS-OSGeo4W-3.4.14-1-Setup-x86_64.exe 07-Dec-2019 16:41 452M)
shows the described problems.

@jef-n any idea?

@gioman gioman added the Processing Relating to QGIS Processing framework or individual Processing algorithms label Dec 15, 2019
@gioman
Copy link
Contributor

gioman commented Dec 15, 2019

@jef-n any idea?

PS no issues on the latest 3.10

@0verlord84
Copy link

0verlord84 commented Dec 16, 2019

I have just installed QGIS ver 3.10.1 but it spits out the same error when I try and run gdal_merge from the GUI.

I have set the PYTHONPATH as C:\Program Files\QGIS 3.10\apps\Python37
GDAL_DATA is at C:\PROGRA~1\QGIS3~1.10\share\gdal
GDAL_DRIVER_PATH is at C:\PROGRA~1\QGIS3~1.10\bin\gdalplugins
PYTHONHOME is the same as PYTHONPATH

The gdal_merge.py (among other gdal modules) are in this folder though (C:\Program Files\QGIS 3.10\apps\Python37\Scripts), which I have tried to point to that path from QGIS as the PYTHONPATH, but unsuccessfully because gdal_merge does not run properly.

I wonder whether it's because I should have installed it via OSGEO4W and point QGIS to those folders instead of the native QGIS ones

@agiudiceandrea
Copy link
Member

@0verlord84

The gdal_merge.py (among other gdal modules) are in this folder though (C:\Program Files\QGIS 3.10\apps\Python37\Scripts), which I have tried to point to that path from QGIS as the PYTHONPATH, but unsuccessfully because gdal_merge does not run properly.

This is strange... both the user on the QGIS-User ML and the user on StackExchange have solved the problem [1][2] properly setting the PYTHONPATH environmental variable.

@tonalitydata
Copy link

I got the same error, and like a virus, it happened on all the computers in my office. I even installed 3.4 on a brand new computer and got the same error. I clearly remember that it worked well last week. It took me a whole day.

@jef-n jef-n self-assigned this Dec 17, 2019
@jef-n
Copy link
Member

jef-n commented Dec 17, 2019

Fixed in OSGeo4W

@agiudiceandrea
Copy link
Member

agiudiceandrea commented Dec 26, 2019

Hi @jef-n and @gioman, there are various similar reports on some mailing lists and forums/groups regarding also QGIS 3.10.1 with GDAL 3, but it seems the fix only affected the OSGeo4W "python3-gdal2" and "gdal2-python" packages, isn'it?

@Gjanosh61
Copy link

The problem was solved by following this procedure:

  • search, in the QGIS installation directory, for the folder where the gdal_merge.py, gdal_polygonize.py, etc. files are present. In your case it could be: G: \ QGIS3 ~ 1.10 \ apps \ Python37 \ Scripts
  • in the QGIS window from the Settings / Options ... / System menu you must insert a new row in the "Environment" box, with the value "Overwrite" (or "Prepend") in the first column ("Apply"), the value " PYTHONPATH "in the second column (" Variable "), and in the third column (" Value ") the path of the above folder.

Annotazione 2019-12-26 213901

@0verlord84
Copy link

0verlord84 commented Dec 27, 2019 via email

@agiudiceandrea
Copy link
Member

agiudiceandrea commented Dec 28, 2019

Now, after the latest fix, it should be sufficient to update python3-core to python3-core-3.7.0-4 via OSGeo4W setup to solve the issue.

@ThomasG77
Copy link
Contributor

ThomasG77 commented Jan 15, 2020

To avoid to set variables in QGIS or in the OS, you should better set the missing variables in the qgis.bat file in C:\Program Files\QGIS 3.10 (path may change depending of the QGIS version)
When you click on the QGIS icon, it's this qgis.bat that is executed before running qgis-bin.exe (the real QGIS executable behind the scene on Windows).

The main advantage is to be able to patch all computers with the same issue by copying the file instead of setting the fix manually for each one. See selected part in the attached image below (PS: do not copy the other lines as they may be specific to my QGIS version). You may need to change Python37 part in the path if the Python version is 3.6 (I do not know which version of Python is bundled with each version of QGIS in the Windows installers).

Sélection_130

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! High Priority Processing Relating to QGIS Processing framework or individual Processing algorithms Regression Something which used to work, but doesn't anymore
Projects
None yet
Development

No branches or pull requests

9 participants