I have a Python script that batch converts GPX files stored on an older Garmin unit to ESRI shapefiles. This script use an ogr2ogr command line argument passed from Python using subprocess.call() to do the conversions. This all works very nicely on my Linux computer that I typically use for script development. I have full permissions on this computer.

Now I am converting the script to a Windows specific computer to which I do not have administrative rights. Furthermore, my Python environment is behind a walled-garden using ArcGIS Pro 2.7. When my script gets to the ogr2ogr conversion and subprocess.call() I get an error message 'ogr2ogr' is not recognized as an internal or external command, operable program or batch file.

A previous post referring to Windows 7 stated that one should either set Environment Path Variables (which I cannot do since I do not have admin rights or run this command line statement "set path=%path%;C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\site-packages\osgeo\". As a test of all this I can run "set path" stuff without error in a Windows Power Shell but when I use the power shell to run ogr2ogr -f " Shapefile" Waypoint.shp Waypoints_01-OCT-19.gpx in the directory with the GPX I get the error below.

`ogr2ogr : The term 'ogr2ogr' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ ogr2ogr -f "ESRI Shapefile" Waypoint.shp Waypoints_01-OCT-19.gpx
+ ~~~~~~~
    + CategoryInfo          : ObjectNotFound: (ogr2ogr:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException`

How do I get my ogr2ogr command to run using Python and Windows 10?

  • 1
    You can set user (not system) environment variables in Windows 10 without admin rights. However, that's not going to help much as the ArcGIS Pro python doesn't include the GDAL/OGR commandline utilities, just the python bindings. You need to use conda to create a new python env that includes a full GDAL.
    – user2856
    Commented Feb 19, 2021 at 20:27
  • Ah, thanks @user2856. Is there a way to use the existing ESRI GDAL Python binding to do the conversion? I can't find a conversion function in the OGR API.
    – GBG
    Commented Feb 19, 2021 at 20:51
  • 1
    @user30184 gdal.VectorTranslate I think you mean, not gdal.Translate
    – user2856
    Commented Feb 19, 2021 at 21:24
  • subprocess takes an env argument where you can pass a dictionary of variables so you don't need to mess with the system. Run set from the osgeo shell to see what you might need to include there. You can also use the full path to the executable so it doesn't need to be discoverable via the system path, but depending on what you're doing GDAL might need some of those extra variables (PROJ_LIB, etc.)
    – mikewatt
    Commented Feb 19, 2021 at 22:04
  • Thanks, everyone. gdal.VectorTranslate worked perfectly.
    – GBG
    Commented Feb 19, 2021 at 22:44

1 Answer 1


The ArcGIS Pro python environment doesn't include the GDAL/OGR commandline utilities, just the python bindings.

You can use gdal.VectorTranslate to do the same thing as ogr2ogr.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.