Right now, setup.py raises a NameError:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-build-wfl5rbpb/fiona/setup.py", line 193, in <module>
if gdalversion.startswith("1"):
NameError: name 'gdalversion' is not defined
I had the same issue, and found it was down to Python not finding the gdal-config executable. So in the first instance, I would check you have the GDAL bin directory in your PATH.
For myself, however, this wasn't possible as I was compiling on Windows (long story) for which there doesn't seem to be a gdal-config available. My work-around was to create a batch script which simulated this program (see below), and then set the GDAL_CONFIG environment variable to the name of the batch script.
The alternative approach of editing the setup.cfg wasn't possible as I was installing via pip.
@echo off
set OPTION=%1
IF "%OPTION%"=="--cflags" (
echo -I_<path to GDAL include directory>
) ELSE IF "%OPTION%"=="--libs" (
echo -L_<path to GDAL lib directory>_ -lgdal_i
) ELSE IF "%OPTION%"=="--datadir" (
echo <path to GDAL data directory (%GDAL_DATA% if you're using OSGeo4W)>
) ELSE IF "%OPTION%"=="--version" (
echo <GDAL version (e.g. 2.1.0)>
)
A little tangential:
gdal-config is a pretty easy concept of dump all the configuration environmental variables into one place and have command line options that query them. I wonder if gdal-config could be partially ported for Windows using Powershell (yuck!) or Python. Python would not be a bad choice because it is already used by many GDAL utilities.
I should throw in that bash is supported on Windows 10, but I don't know much about that.
This bug is in fact incredibly frustrating, as it interacts with #259. I would like to upgrade to version 1.7 to get the necessary fix but the Win64 Conda channel has not yet been upgraded to 1.7. I'm trying to use pip but instead get this error.
I cannot downgrade GDAL because doing so forces my NumPy/Pandas stack to downgrade and breaks my code. This whole thing feels like an exercise in futility.
@achamberlain @micahcochran in the future, pip will not execute setup.py and will install only wheels. I recommend running the setup.py script as we do for Appveyor, see https://github.com/Toblerity/Fiona/blob/master/appveyor.yml#L92, instead of porting gdal-config.
@PeterKucirek I'm very sorry about your frustration. I don't have any plans right now to publish Win64 Fiona wheels to PyPI, mostly because I don't have adequate experience building GDAL on Windows. Have you tried the conda-forge channel? I see Win64 wheels for 1.7 there: https://anaconda.org/conda-forge/fiona/files.
Do I actually need to build GDAL, though? I mean, it's already on Conda, so presumably I have no need for the Fiona install to do it. The problem appears to be that the Fiona setup script is having trouble finding which version of GDAL is installed. I've tried pip install --upgrade --install-options="--gdalversion=2" to try to force setup.py to 'see' the proper version, but to no avail.
Most helpful comment
I had the same issue, and found it was down to Python not finding the
gdal-configexecutable. So in the first instance, I would check you have the GDAL bin directory in yourPATH.For myself, however, this wasn't possible as I was compiling on Windows (long story) for which there doesn't seem to be a
gdal-configavailable. My work-around was to create a batch script which simulated this program (see below), and then set theGDAL_CONFIGenvironment variable to the name of the batch script.The alternative approach of editing the setup.cfg wasn't possible as I was installing via pip.
@echo offset OPTION=%1IF "%OPTION%"=="--cflags" (echo -I_<path to GDAL include directory>) ELSE IF "%OPTION%"=="--libs" (echo -L_<path to GDAL lib directory>_ -lgdal_i) ELSE IF "%OPTION%"=="--datadir" (echo <path to GDAL data directory (%GDAL_DATA% if you're using OSGeo4W)>) ELSE IF "%OPTION%"=="--version" (echo <GDAL version (e.g. 2.1.0)>)