I'm writing a standalone PyQGIS application. In order to set the project CRS, I'm using the QgsCoordinateReferenceSystem class. I tried all the possible methods to assign the crs I want (which is EPSG:32632, but I also tried with the standard EPSG:4326), and none is working (failure verified with isValid method). When I use QgsCoordinateReferenceSystem.createFromUserInput('EPSG:32632), I get the following error:

ERROR 4: ERROR 4: Unable to open EPSG support file gcs.csv. Try setting the GDAL_DATA environment variable to point to the directory containing EPSG csv files.

I therefore deduced that this could be the problem preventing every method I tried from working. However, the GDAL_DATA path is set in my batch file running the script by calling the o4w_env.bat, and it is correctly set to the default for OSGeo4W64 installation, which is C:\OSGeo4W64\share\gdal.

The file gcs.csv is correctly located in the pointed directory. Within my script, I repeatedly verify the GDAL_DATA variable, as well as GDAL_DRIVER_PATH, GEOTIFF_CSV and PROJ_LIB: they're all set to the default values for OSGeo4W64 installation, and are never changed within the script.

Since all the paths are correct, and the gcs.csv is actually located in the pointed directory, I can't really get where the issue might be rising from.

1 Answer 1


In the end I figured out it was an enviroment setting problem. However it was not related to the GDAL_DATA path, but to QGIS_PREFIX_PATH (NOTE: settings are referred to standard OSGeo4W64 installation on Windows 10).

I already had the following:

os.environ['QGIS_PREFIX'] = 'C:/OSGeo4W64/apps/qgis'
os.environ['GDAL_DATA'] = 'C:/OSGeo4W64/share/gdal'

Adding the following line solved the issue:

os.environ['QGIS_PREFIX_PATH'] = 'C:/OSGeo4W64/apps/qgis'

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.