1

When I import geopandas I get the follwing warning:

Warning 3: Cannot find header.dxf (GDAL_DATA is not defined)
Cannot find header.dxf (GDAL_DATA is not defined)

Though everything seems to be working correctly, I would really like to know what the reason for this warning is and how to solve it.

I installed GeoPandas on my Windows machine using Anaconda install (and conda-forge).

Package versions: GeoPandas: 0.14.3 GDAL: 3.8.4

3
  • 1
    set GDAL_DATA=C:\gdal\data see stackoverflow.com/questions/45883445/… - its setting the version of AutoCAD see help.autodesk.com/view/ACD/2023/ENU/…
    – Mapperz
    Commented Mar 6 at 18:50
  • I recall having had these kind of issues, possibly linked to the environment not getting activated properly, in the past when I had multiple installations of anaconda/miniconda/miniforge on one computer. Could that be the case? Unistalling all installations and reinstalling one helped me back then, but if you have many environments this can be a pain...
    – Pieter
    Commented Mar 7 at 7:03
  • I tried to do this as I had one other environment containing GeoPandas, however it didn´t solve the issue. However, I found a solution within the answer of Mapperz. Commented Mar 7 at 14:23

2 Answers 2

1

Often the reason is that for some reason your environment is not in its best shape.

A good first thing to do is to make sure that you don't mix packages from different conda channels. I would try to create a new environment like this:

conda create -n geo
conda activate geo
conda config --env --add channels conda-forge
conda config --env --set channel_priority strict
conda install python=3.11 geopandas
1
  • 1
    I forgot to say, I already used conda-forge setting up my environment. I´ll update that in the question. I also tried setting up a new approach as in your answer but the result is the same, unfortunately. Commented Mar 6 at 21:16
1

Using the comment of @Mapperz, I was able to resolve it.

By adding the following code the warning does not appear:

import os
import sys

os.environ['GDAL_DATA'] = os.path.join(f'{os.sep}'.join(sys.executable.split(os.sep)[:-1]), 'Library', 'share', 'gdal')

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.