[gdal-dev] The proper way to call gdal "scripts" on Windows?

Idan Miara idan at miara.com
Thu Feb 25 01:15:24 PST 2021


Hi Mateusz and Richard,

Thanks for your prompt responses.
I had the scripts folder in my path.
It seems that the issue was indeed that I had PyCharm associated with .py
files, so calling `gdal_calc` or `gdal_calc.py` (from cmd for instance)
just opened gdal_calc.py in PyCharm.
Once I've changed py files to be associated with python.exe instead of with
PyCharm then I could also run gdal_calc from cmd just by calling
`gdal_calc` or `gdal_calc.py`.

I guess that because I had `scripts` in my path I expected that `python
gdal_calc.py` would also work (unrelated to which application is associated
with py files), but it seems that it only works for files in the current
dir or when providing a full path, and it doesn't work for files in the
path (unless you cd to that dir).
Richard - I'm not sure which batch files you were referring to, which gdal
distribution created gdal_calc.bat files for you?

Idan



On Thu, 25 Feb 2021 at 10:50, Richard Duivenvoorde <rdmailings at duif.net>
wrote:

> For what I know
> C:\>gdal_calc
> should work: apparently the c:\Python38\Scripts is added to your PATH
> variable, and you can call this ('bat'-file?) from everywhere on your
> system.
>
> What can be an issue is that with the installation of python 3.8 you
> 'associated' the 'py' extension (so how to handle *.py files) with the
> Idle-python programming IDE.
>
> I think it is possible to just remove that association. And then a call to
> gdalcalc should work.
> IF NOT: have a look into the gdalcalc file (the bat script) and fix things
> there.
>
> Hope this helps,
>
> Richard Duivenvoorde
>
> On 2/25/21 9:33 AM, Idan Miara wrote:
> > Hi All,
> >
> > I was wondering what is the proper way to call the gdal scripts that are
> installed on the "Python3X\Scripts" on Windows.
> >
> > Is there an easier way but to call "python
> c:\Python38\Scripts\gdal_calc.py", for instance?
> > I do have the scripts folder in my path.
> >
> > # this opens gdal_calc.py with my IDE
> > C:\>gdal_calc
> >
> > # this opens gdal_calc.py with my IDE as well
> > C:\>gdal_calc.py
> >
> > C:\>python gdal_calc.py
> > python: can't open file 'gdal_calc.py': [Errno 2] No such file or
> directory
> >
> > C:\>python c:\Python38\Scripts\gdal_calc.py
> > Usage: gdal_calc.py --calc=expression --outfile=out_filename [-A
> filename]
> >                     [--A_band=n] [-B...-Z filename] [other_options]
> >
> > Regards,
> > Idan
> >
> > _______________________________________________
> > gdal-dev mailing list
> > gdal-dev at lists.osgeo.org
> > https://lists.osgeo.org/mailman/listinfo/gdal-dev
> >
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20210225/fa58a9da/attachment.html>


More information about the gdal-dev mailing list