1

I am trying to run some notebooks that make use of gdal library. I have followed instructions to install it, sometimes the step 5 works well and other does not, showing this error message: ModuleNotFoundError: No module named 'gdal'

Step 1

$ apt update

Step 2

$ apt install libgdal-dev -y

Step 3

$ apt install python-gdal -y

Step 4

$ apt install python-numpy python-scipy -y

Step 5

import gdal  # fingers crossed!

I have installed gdal library working well on my machine, but I understand, under colaboratory, it install gdal on the server.

Any suggestions?

Seanny123
  • 8,776
  • 13
  • 68
  • 124
Bayes
  • 107
  • 1
  • 11
  • have you tried to install gdal through pip? maybe `pip install gdal`? – Fabián Montero Aug 28 '18 at 14:43
  • Yeah. It generates this error: Failed building wheel for gdal Running setup.py clean for gdal Failed to build gdal: Command "/usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-u_qz0bl7/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/pip-record-1i6tkzli/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-install-u_qz0bl7/gdal/ – Bayes Aug 28 '18 at 14:56
  • Do `pip install -U setuptools` and `pip install -U wheel` and try again. @jaime-lopez – Fabián Montero Aug 28 '18 at 15:00
  • Hi @machetazo, I followed your suggestion, and I got this: Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-zxxgac1s/gdal/. – Bayes Aug 28 '18 at 16:52
  • try this `pip install --upgrade setuptools` and `pip install ez_setup` and try again. If it doesn't work, do `easy_install -U setuptools` and try again. – Fabián Montero Aug 28 '18 at 16:55
  • Hi @machetazo, I got this one after that: Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-2gfcbr2z/gdal/. Any other suggestion? I will appreciate it. – Bayes Aug 28 '18 at 23:53
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/178982/discussion-between-machetazo-and-jaime-lopez). – Fabián Montero Aug 29 '18 at 02:48
  • I am thinking this error could be related to python version, I mean, I followed the steps for python 2.7, but I have python 3.6. Any suggestion about this? – Bayes Aug 30 '18 at 12:18
  • See my answer on https://stackoverflow.com/questions/70275565/how-to-install-gdal-on-google-colab-fast – sam_cocha Mar 31 '22 at 13:10

0 Answers0