Does anyone know why the pip install of gdal never seems to work? I am asking out of genuine curiosity and don't intend to sound negative. I have a related downstream packaging issue with GDAL as a dependency, but was just wondering why this installation has persisted for such a long time. Because of the pip errors, I actually have to develop my package for conda-forge instead of PYPI. My usual workaround for gdal is to use the conda-forge installation of gdal.

I get all kinds of errors whenever I try and install gdal. I get different kinds of errors each time I try and install it.

For example, if I use Anaconda to create a new environment:

conda create -n myenv python=3.6
conda activate myenv
pip install gdal

I will either get errors about broken wheels or I get an error such as this about gcc:

    error: command 'gcc' failed with exit status 1
ERROR: Command errored out with exit status 1: /media/xxx/t_gdal/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/xxx/pip-install-bmel7ik_/gdal/setup.py'"'"'; __file__='"'"'/tmp/xxx/pip-install-bmel7ik_/gdal/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/xxx/pip-record-df_uldmb/install-record.txt --single-version-externally-managed --compile --install-headers /media/xxx/anaconda3/envs/t_gdal/include/python3.6m/gdal Check the logs for full command output.

Here are other folks who have had similar issues installing gdal.

Python GDAL package missing header file when installing via pip

How to (re)install gdal in python3 (mac)?


Installing GDAL and OGR for Python?

Is gdal one of the cases where pip does not work well, because of all the C and C++ compilation, etc? I was just wondering what the cause was.

  • @user2856 yep, I am definitely using the conda-forge version of gdal, which works pretty reliably. But I am developing a package that I want to open source, and seems like I have to now use conda and conda-forge instead of pip and PYPI. So if that is the way that things are that is fine, but was just wondering if I can get away with using pip alone? That is why I was curious about this. – krishnab Aug 1 at 1:48
  • @user2856 that makes a lot more sense, and that validates kinda what I imagined was the issue. So pip is good at python source packages, but has a harder time with compiled extensions and things. So this is where a package manager like conda would work better in most cases. That clarifies the underlying issue. Thanks again for all of your help. – krishnab Aug 1 at 3:28

Your Answer

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

Browse other questions tagged or ask your own question.