[gdal-dev] How to fix path for gdal .py scripts in Anaconda-Windows?
Matt.Wilkie at yukon.ca
Matt.Wilkie at yukon.ca
Wed Jan 12 15:40:50 PST 2022
Also see OSGEO4W make-bat-for-py.bat<https://trac.osgeo.org/osgeo4w/ticket/17>. Old but still works. ;-)
```
for %%g in (*.py) do (
echo @python "%%~dpnxg" %%* > %%~ng.bat
)
```
You should be able to insert settings if needed for environment variables (I didn’t test this particular formulation):
```
@echo off
for %%g in (*.py) do (
@echo @python "%%~dpnxg" %%*
if not exist %%~ng.bat (
echo “set PYTHONHOME=C:\PROGRA~1\QGIS32~1.2\apps\Python39” > %%~ng.bat
echo “set PYTHONUTF8=1” >> %%~ng.bat
echo @python "%%~dpnxg" %%* >> %%~ng.bat
)
```
-Matt
From: gdal-dev <gdal-dev-bounces at lists.osgeo.org> On Behalf Of Idan Miara
Sent: January 12, 2022 2:27 PM
To: Rafael Lima <raplima at hotmail.com>
Cc: gdal dev <gdal-dev at lists.osgeo.org>
Subject: Re: [gdal-dev] How to fix path for gdal .py scripts in Anaconda-Windows?
Hi,
I had the same problem, here's my solution :
https://github.com/OSGeo/gdal/blob/master/swig/python/gdal-utils/osgeo_utils/auxiliary/batch_creator.py
Idan
On Wed, 12 Jan 2022, 23:22 Rafael Lima, <raplima at hotmail.com<mailto:raplima at hotmail.com>> wrote:
I thought about uninstalling it to lol
checking that PYTHONPATH or PYTHONHOME are not defined to an unexpected value will be sufficient
It was something of the sorts. The paths were actually fine, but the "default windows app" is activated when calling a file with a .py extension. So calling ogrmerge.py on the terminal would activate the default app instead of the activated python =/
Thanks!
________________________________
De: gdal-dev <gdal-dev-bounces at lists.osgeo.org<mailto:gdal-dev-bounces at lists.osgeo.org>> em nome de Even Rouault <even.rouault at spatialys.com<mailto:even.rouault at spatialys.com>>
Enviado: quarta-feira, 12 de janeiro de 2022 16:09
Para: gdal-dev at lists.osgeo.org<mailto:gdal-dev at lists.osgeo.org> <gdal-dev at lists.osgeo.org<mailto:gdal-dev at lists.osgeo.org>>
Assunto: Re: [gdal-dev] How to fix path for gdal .py scripts in Anaconda-Windows?
I would have suggested to uninstall the offending proprietary software :-), but perhaps checking that PYTHONPATH or PYTHONHOME are not defined to an unexpected value will be sufficient
Le 12/01/2022 à 19:24, Rafael Lima a écrit :
## Expected behavior and actual behavior.
I installed gdal on a Windows environment using anaconda and tried using one of the .py scripts (e.g., ogrmerge.py). I expected the script to make use of the gdal installed in such an environment, but it seems that the script finds another gdal installation (screenshot below), thus throwing an error. My question seems to be related to the one in https://stackoverflow.com/questions/69328298/cannot-run-a-py-which-requires-a-gdal-module-in-anaconda-prompt-nor-in-command, apparently unsolved. I was wondering what is the correct approach to make sure gdal scripts find the correct gdal?
## Steps to reproduce the problem.
create a conda environment:
conda create -n test1 gdal
activate the environment
conda activate test1
call a gdal .py script
ogrmerge.py
In my case, that throws an error apparently because the script uses another gdal installation:
[cid:part1.66CDEAD4.863B431E at spatialys.com]
## Operating system
Windows 10 Pro - 20H2 version
## GDAL version and provenance
GDAL==3.0.2
GDAL==3.4.0
Thank you!
Rafael
_______________________________________________
gdal-dev mailing list
gdal-dev at lists.osgeo.org<mailto:gdal-dev at lists.osgeo.org>
https://lists.osgeo.org/mailman/listinfo/gdal-dev
--
http://www.spatialys.com
My software is free, but my time generally not.
_______________________________________________
gdal-dev mailing list
gdal-dev at lists.osgeo.org<mailto: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/20220112/b90bbb8f/attachment-0001.html>
More information about the gdal-dev
mailing list