I use Windows 10, have Python 2.7 installed as part of ArcGIS 10.5. I have installed GDAL using a package manager that runs fine in Python, meaning I can import both gdal and ogr in a Python editor. But when I try to install it using virtualenv, things don´t work - I can´t install GDAL properly. I have tried various other solutions, such as specifying the GDAL version, but I cannot install GDAL using virtualenv. How can I install it using virtualenv?

(venv) C:\Home\venv\Scripts>pip install gdal
Collecting gdal
  Using cached GDAL-2.1.3.tar.gz
Building wheels for collected packages: gdal
  Running setup.py bdist_wheel for gdal ... error
  Complete output from command c:\home\venv\scripts\python.exe -u -c "import setuptools, tokenize;__file__='c:\\users\\eric\\appdata\\local\\temp\\pip-build-ox37ve\\gdal\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d c:\users\eric\appdata\local\temp\tmpfydmk9pip-wheel- --python-tag cp27:
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build\lib.win32-2.7
  copying gdal.py -> build\lib.win32-2.7
  copying ogr.py -> build\lib.win32-2.7
  copying osr.py -> build\lib.win32-2.7
  copying gdalconst.py -> build\lib.win32-2.7
  copying gdalnumeric.py -> build\lib.win32-2.7
  creating build\lib.win32-2.7\osgeo
  copying osgeo\gdal.py -> build\lib.win32-2.7\osgeo
  copying osgeo\gdalconst.py -> build\lib.win32-2.7\osgeo
  copying osgeo\gdalnumeric.py -> build\lib.win32-2.7\osgeo
  copying osgeo\gdal_array.py -> build\lib.win32-2.7\osgeo
  copying osgeo\gnm.py -> build\lib.win32-2.7\osgeo
  copying osgeo\ogr.py -> build\lib.win32-2.7\osgeo
  copying osgeo\osr.py -> build\lib.win32-2.7\osgeo
  copying osgeo\__init__.py -> build\lib.win32-2.7\osgeo
  running build_ext
  building 'osgeo._gdal' extension
  creating build\temp.win32-2.7
  creating build\temp.win32-2.7\Release
  creating build\temp.win32-2.7\Release\extensions
  C:\Users\Eric\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -I../../port -I../../gcore -I../../alg -I../../ogr/ -I../../ogr/ogrsf_frmts -I../../gnm -I../../apps -IC:\Python27\ArcGIS10.5\include -Ic:\home\venv\PC -Ic:\home\venv\lib\site-packages\numpy\core\include /Tpextensions/gdal_wrap.cpp /Fobuild\temp.win32-2.7\Release\extensions/gdal_wrap.obj
  C:\Users\Eric\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Include\xlocale(342) : warning C4530: C++ exception handler used, but unwind semantics are not enabled. Specify /EHsc
  extensions/gdal_wrap.cpp(3085) : fatal error C1083: Cannot open include file: 'cpl_port.h': No such file or directory
  error: command 'C:\\Users\\Eric\\AppData\\Local\\Programs\\Common\\Microsoft\\Visual C++ for Python\\9.0\\VC\\Bin\\cl.exe' failed with exit status 2

1 Answer 1


Download GDAL‑2.1.3‑cp27‑cp27m‑win32.whl from Christoph Gohlke's unnofficial python packages for Windows.

pip install path\to\GDAL‑2.1.3‑cp27‑cp27m‑win32.whl
  • 1
    I have downloaded a wheel file form Cristoph's repo and was successful using pip installing it on the system, but failed to install the wheel in the virtualenv.
    – icypy
    Dec 3, 2019 at 19:25

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.