Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#594 closed defect (worksforme)

GDAL Python scripts can not be run

Reported by: alexbruy Owned by: osgeo4w-dev@…
Priority: major Component: Package
Version: Keywords: gdal, python, scripts
Cc: gioman


Looks like there is something wrong with GDAL Python scripts (e.g., etc) setup in OSGeo4W.

When trying to run any of the Processing tools in QGIS which are based on GDAL Python scripts, they fails with message saying that corresponding GDAL script is not found. Same happens with trying to run them from the OSGeo4W shell directly.

Here is steps to reproduce using OSGeo4W shell:

  1. open OSGeo4W shell
  2. setup Python by running py3_env.bat
  3. try to execute for example with
  4. execution failed with error
    (null): can't open file '': [Errno 2] No such file or directory

Same error when running from QGIS Processing.

Related QGIS issue

Change History (4)

comment:1 Changed 3 years ago by jef

Did you install python3-gdal?

comment:2 Changed 3 years ago by alexbruy

Yes, python3-gdal 2.4.0-5 installed, GDAL scripts present in the %OSGEO4W_ROOT%\apps\Python37\Scripts and can be executed when full path specified.

comment:3 Changed 3 years ago by Mike Toews

Generally speaking, calling python should normally show "python: can't open file '': [Errno 2] No such file or directory", unless that file exists in the current directory.

With OSGeo4w's Shell, these commands are normally run by their name without any extension:

Usage: --calc=expression --outfile=out_filename [-A filename]
                    [--A_band=n] [-B...-Z filename] [other_options]

Internally, the Python scripts are usually run with a tiny BAT script, e.g. see where gdal_calc for the full path of the thing that CMD calls:

C:\>where gdal_calc

C:\>cat C:\OSGeo4W64\bin\gdal_calc.bat
@echo off
call "%OSGEO4W_ROOT%\bin\o4w_env.bat"
python "%OSGEO4W_ROOT%\bin\" %*

comment:4 Changed 3 years ago by jef

Resolution: worksforme
Status: newclosed

The QGIS problem is fixed by running "python3 -m gdal_calc …"

Last edited 3 years ago by jef (previous) (diff)
Note: See TracTickets for help on using tickets.