I created a PyQGIS standalone script in PyCharm my script use rasters layers but any time to try to run it I take this error message:

Warning 1: Cannot find pcs.csv
Warning 1: Cannot find datum.csv or gdal_datum.csv
Warning 1: Cannot find ellipsoid.csv
Warning 1: Cannot find prime_meridian.csv
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.

But I have defined GDAL_DATA in the Windows environment:


I try to add path in PyCharm:

enter image description here

And I try to add path with sys.path.append and nothing again. I have checked all files in error message is in the GDAL PATH.

Any idea why I can't define GDAL_DATA?

1 Answer 1

  1. Make sure you have restarted PyCharm after setting the Windows environment variable
  2. Make sure you don't have a space (e.g. "GDAL_DATA ") in the Windows environment variable (I got bit by that last week after copy/pasting an env var name from a web page)
  3. The paths you added in PyCharm won't work, that's for python paths not general environment variables. You can set an environment variable on a per script basis in the Run->Edit Configurations...->Your Script run config dialog
  4. As a last resort, you can set an environment variable in your script using os.environ['GDAL_DATA'] = r'C:\Program Files\QGIS etc...'
  • hello I have space in path in Program Files and QGIS 2.18 that the problem ?
    – Mar
    Jul 7, 2017 at 13:02
  • edit the path like this r'C:\ProgramFiles\QGIS2.18\share\gdal ?
    – Mar
    Jul 7, 2017 at 13:12
  • No, I mean space in the variable name, not the variable value.
    – user2856
    Jul 7, 2017 at 13:17
  • I mean I have space in path not in variable name
    – Mar
    Jul 7, 2017 at 13:18
  • That doesn't matter
    – user2856
    Jul 7, 2017 at 13:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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