I installed GDAL and its Python bindings from GISInternals. While I believe that GDAL was installed correctly, the Python bindings have an issue.

After opening a file with gdal.open I cannot read the file as an array. The error message is saying: No module named '_gdal_array'. I installed the following Python bindings: GDAL-2.1.0.win-amd64-py3.4.msi, but tried it before with the bindings for Python 2.7.

Then I read somewhere that the OsGeo4W project should be able to give you correct Python bindings. I went into the Lib-directory and selected the Python bindings, installed the library together with its dependencies. When the program was downloading the data for installation it was already clear that something was strange. During the installation then, I saw that some Python 2.7.4 stuff was going to be installed.

Python in my registry is 3.4 and the other Python, of version 2.7, that is installed belongs to ArcGIS and I rather want to have that stuff untouched...

All I can say is, that I cannot see that the OsGEO4W gave me anything useful. The Python bindings for Python 3.4 still do not allow me to read my data as array...

I need to have the Python bindings working properly for a 64-bit version of Python, and it seems as if I cannot get bindings that actually allow me to read my data as array.

Any help on how I can get the Python bindings to work correctly?

  • I can understand your frustration but the problem lies not with OsGeo4W but your understanding/control of it. OsGEo4W does give you a full set of GDAL Python bindings. Likewise the Python bindings from GISINternals (an excellent source). To get help with this please can you add more information about your system. What are the environment variables set to for Python (this is likely to be the crux of the problem)? What version of MSVC do you have installed and what version of GDAL did you try to install from GISInternals? Do you have 64 or 32 bit Windows – MappaGnosis Oct 10 '16 at 11:43
  • Thanks for your comment! I am running a Windows 7 (64-bit) OS, apart from the Python installed during the ArcGIS installation, there is a Python 2.7.12 (64-bit) installed. In addition also Python 3.4.4 (64-bit). Initially did I install GDAL 2.1.0 core from GISInternals, at that time for a 32-bit Python 2.7.12, likewise the Python bindings. That constellation was able to read a GDAL file object using ReadAsArray. However, a consequtive numpy.unique fails. My arrays have shape of 25000, 25000! Hence, my efforts to get everything running in 64-bit. There is no MSVC on my system. – Thomas Becker Oct 10 '16 at 11:56
  • Looking at the installed programs I can see an MVC 2 and MVC 2 - Visual Studio 2010 Tools. However, installing GDAL Python bindings with pip fails with error: Microsoft Visual C++ 10.0 is required (Unable to find vcvarsall.bat). Python 3.4 is within the system path, as well as GDAL 2.1.0. The GDAL DATA variable is also set. – Thomas Becker Oct 10 '16 at 12:30
  • The problem is that most of the python gdal/ogr bindings from GISInternals doesn't seem to be compiled with numpy and there are created several issues in the GISInternal tracker describing the problem. One of them has feedback from Tamaz Szekeres, but I'm not sure how far he got solving the problem. – Chau Apr 19 '17 at 13:20

I posted a tutorial on how to setup GDAL for python 2.7, I haven't tested it for newer versions of python, but here it is: https://github.com/felipunky/GISPython

| improve this answer | |

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.