1

I am having a similar problem as to installing gdal using pip. However, I am using Windows 10. The resulting error when I type pip install gdalin powershell is extensions/gdal_wrap.cpp(3085): fatal error C1083: Cannot open include file: 'cpl_port.h': No such file or directory error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\x86_amd64\\cl.exe' failed with exit status 2

I tried all the methods mentioned in the original question's answer.

P.S.: I would have added this as a comment, but you need minimum 50 reputations and I am new here.

Community
  • 1
  • 1
Ajar
  • 29
  • 5
  • Possible duplicate of [Python GDAL package missing header file when installing via pip](http://stackoverflow.com/questions/11336153/python-gdal-package-missing-header-file-when-installing-via-pip) – Renats Stozkovs Feb 27 '17 at 16:40
  • 1
    I have seen that page. But all the answers are for ubuntu interface. I am working with Windows and somehow it does not work. – Ajar Feb 27 '17 at 16:46

1 Answers1

3

On Windows 10 I was able to install into a virtual environment (python -m venv myenvironment). I did install OSGeo4W64 but I didn't want to use that python because I'm using Anaconda python 3.6, so I did this from within my virtual environment:

pip install gdal==2.2.2 --global-option=build_ext --global-option="-IC:/OSGeo4W64/include/" --global-option="-LC:/OSGeo4W64/lib/"

I also needed to set environment variables as discussed in https://docs.djangoproject.com/en/1.11/ref/contrib/gis/install/#modify-windows-environment.

I haven't tested much yet, but so far from osgeo import gdal works

User
  • 62,498
  • 72
  • 186
  • 247
  • Just for comment, I did not found GDAL's headers for 64 bits distribution, so I needed to execute the following command: `pip install gdal==3.4.0 --global-option=build_ext --global-option="-IC:/OSGeo4W/include/" --global-option="-LC:/OSGeo4W/lib/"` – joninx Dec 21 '21 at 16:20