5

I attempted to use GDAL without installing due to not having rights to install on this computer. I managed to get several gdal modules working, but when I attempted to use ReadAsArray() I received the import error

ImportError: No module named _gdal_array

I looked through the python folder and found that gdal and gdalconst both had pyd files and compiled files, but gdal_array does not.

When I ran VersionInfo() I got the value 1910 for gdal if that helps. I also have python 2.6 and numpy

Does anyone know a way I could fix this problem without using a gdal installer?

4
  • Are you on Windows?
    – ustroetz
    Commented Jan 16, 2014 at 1:07
  • @ustroetz Yes, Windows 7
    – Dzinic
    Commented Jan 16, 2014 at 2:14
  • I have the same issue. Using the GDAL 64 bit version, the _gdal_array.pyd is NOT generated and when I call ReadAsArray() is returning the error: ImportError: No module named _gdal_array. Using the GDAL 32 bit version the _gdal_array.pyd file is generated and it is working. How can I solve it? Thanks
    – user66058
    Commented Jan 27, 2016 at 16:08
  • @Federico As I recall, I followed Lafleur's instructions that he posted in my other question (gis.stackexchange.com/questions/82977/…) and it fixed it for me.
    – Dzinic
    Commented Jan 28, 2016 at 20:08

3 Answers 3

6

This happens when numpy was not yet installed during the installation of gdal-python. This normally only affects folks who install using pip and install gdal before numpy. numpy is an optional build requirement and the package will install but quietly not include the _gdal_array component

To resolve, force a reinstall (rebuild of the package), via pip:

  1. pip install numpy
  2. pip install --force-reinstall gdal

or can be done using system package manager.

3
  • 1
    This should be the accepted answer - correct explanation of the reason together with a solution that works. Thank you!
    – johndodo
    Commented Oct 14, 2020 at 8:32
  • 1
    No such luck for me :/
    – Shayne
    Commented Sep 8, 2022 at 5:44
  • @Shayne what does the log say when it builds the _gdal_array module?
    – crasic
    Commented Sep 9, 2022 at 20:19
3

Poking around I figured out that a bunch of gdal bundles are missing files, including the maptools.org ones. http://lists.osgeo.org/pipermail/gdal-dev/2011-May/028708.html

I found a gdal 1.10 version that is working for me. Put the install instructions with the original question: Is it possible to use GDAL without admin rights?

-2

In case you need gdal+python on windows x64, you should compile it manually.

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.