0

I am trying to run Polygonize (Raster to Vector) from QGIS 3.18.3-Zürich inside a conda environment. When running the command, I encountered the following error.

Process gdal_polygonize.bat failed to start. Either gdal_polygonize.bat is missing, or you may have insufficient permissions to run the program.

I am able to load gdal from Python

(geoenv) C:\Users\jaina>python
Python 3.8.12 (default, Oct 12 2021, 03:01:40) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from osgeo import gdal
>>>

Also, gdalinfo works fine. I tried adding gdal scripts directory to the PATH

C:\Users\jaina\.conda\envs\geoenv\Scripts

I also tried this answer to modify system settings in QGIS but it resulted in no module SIP error on starting QGIS and processing tool bar disappears.

/Library/Frameworks/GDAL.framework/Programs:/Library/Frameworks/Python.framework/Versions/3.18.3/bin:

A similar question is unanswered here

EDIT:

Path to gdal_polygonize.bat

C:\Users\jaina\.conda\envs\geoenv>dir /s gdal_polygonize.bat
 Volume in drive C is Windows
 Volume Serial Number is 60CD-213A
File Not Found

Path to gdal_polygonize.py

C:\Users\jaina\.conda\envs\geoenv>dir /s gdal_polygonize.py

 Directory of C:\Users\jaina\.conda\envs\geoenv\Lib\site-packages\GDAL-3.3.2-py3.8-win-amd64.egg-info\scripts

16-10-2021  15:38               330 gdal_polygonize.py

 Directory of C:\Users\jaina\.conda\envs\geoenv\Lib\site-packages\osgeo_utils

01-10-2021  22:52             7,525 gdal_polygonize.py

 Directory of C:\Users\jaina\.conda\envs\geoenv\Scripts

16-10-2021  15:38               210 gdal_polygonize.py

All paths for conda environment

(geoenv) C:\Users\jaina>set PATH
Path=C:\Users\jaina\.conda\envs\geoenv;C:\Users\jaina\.conda\envs\geoenv\Library\mingw-w64\bin;C:\Users\jaina\.conda\envs\geoenv\Library\usr\bin;C:\Users\jaina\.conda\envs\geoenv\Library\bin;C:\Users\jaina\.conda\envs\geoenv\Scripts;C:\Users\jaina\.conda\envs\geoenv\bin;C:\ProgramData\Miniconda3\condabin;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\iCLS;C:\Program Files\Intel\Intel(R) Management Engine Components\iCLS;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\WINDOWS\System32\OpenSSH;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Git LFS;C:\Program Files\dotnet;C:\Users\jaina\.conda\envs\geoenv\Scripts;C:\Users\jaina\AppData\Local\Microsoft\WindowsApps;.
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
4
  • What happens with the Tool? docs.qgis.org/2.14/en/docs/training_manual/complete_analysis/… Oct 16, 2021 at 13:38
  • Sorry did not get the question you asked? Is there something I should be take away from the docs you linked? Oct 16, 2021 at 13:58
  • Did you search where gdal_polygonize.bat is located on your computer using files search? Where is it? Do you have one file, more? Give us the list of paths.
    – ThomasG77
    Oct 16, 2021 at 15:05
  • @ThomasG77 I edited the question to add paths. gdal_polygonize.bat is not present inside my environment. Oct 16, 2021 at 15:20

1 Answer 1

0

Try to create a file $CONDA_PREFIX/bin/gdal_polygonize.bat with your text editor. In your case, it should be C:\Users\jaina\.conda\envs\geoenv\bin\gdal_polygonize.bat

Then, within the file, put the following

@echo off
%CONDA_PYTHON_EXE% "%CONDA_PREFIX%/lib/python3.8/site-packages/osgeo_utils/gdal_polygonize.py" %*

I do not know why but no .bat files were generated when installing conda. You may open an issue at https://github.com/conda-forge/qgis-feedstock/issues

1
  • Since I did not have bin folder, I had to create one. Inside that I created that file with modified code since there was no lib and python3.8 dir. @echo off %CONDA_PYTHON_EXE% "%CONDA_PREFIX%/Lib/site-packages/osgeo_utils/gdal_polygonize.py" %* After that I tried running the processing tool, and now it shows that module osgeo does not exists . It is not reading the correct python execution file. Could this occur as I installed all these packages using miniconda? Attaching a photo i.imgur.com/aFuIz3o.png Oct 17, 2021 at 11:20

Your Answer

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

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