So I am trying to pip install gdal but got an error.
JavaScript
x
3
1
extensions/gdal_wrap.cpp(3168): fatal error C1083: Cannot open include file: 'cpl_port.h': No such file or directory
2
error: command 'C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.13.26128\bin\HostX86\x64\cl.exe' failed with exit status 2
3
So I am running the following:
- Python 3.6.4 anaconda distribution
- Windows 10 (x64)
- Microsoft Visual 2017 Redistribute both x64 and x86 (both installed by the vs builder tool)
MS Visual was installed because of this error before
JavaScript
1
2
1
error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": http://landinghub.visualstudio.com/visual-cpp-build-tools
2
Here is the trace log for the error:
JavaScript
1
39
39
1
C:UsersDesktop>pip install gdal
2
Collecting gdal
3
Using cached GDAL-2.2.4.tar.gz
4
Building wheels for collected packages: gdal
5
Running setup.py bdist_wheel for gdal error
6
Complete output from command c:usersenvsecoscanscriptspython.exe -u -c "import setuptools, tokenize;__file__='C:\Users\0\AppData\Local\Temp\pip-build-wc3za_f8\gdal\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('rn', 'n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d C:UsersAppDataLocalTemptmp9t7nk1ompip-wheel- --python-tag cp36:
7
running bdist_wheel
8
running build
9
running build_py
10
creating build
11
creating buildlib.win-amd64-3.6
12
copying gdal.py -> buildlib.win-amd64-3.6
13
copying ogr.py -> buildlib.win-amd64-3.6
14
copying osr.py -> buildlib.win-amd64-3.6
15
copying gdalconst.py -> buildlib.win-amd64-3.6
16
copying gnm.py -> buildlib.win-amd64-3.6
17
creating buildlib.win-amd64-3.6osgeo
18
copying osgeogdal.py -> buildlib.win-amd64-3.6osgeo
19
copying osgeogdalconst.py -> buildlib.win-amd64-3.6osgeo
20
copying osgeogdalnumeric.py -> buildlib.win-amd64-3.6osgeo
21
copying osgeogdal_array.py -> buildlib.win-amd64-3.6osgeo
22
copying osgeognm.py -> buildlib.win-amd64-3.6osgeo
23
copying osgeoogr.py -> buildlib.win-amd64-3.6osgeo
24
copying osgeoosr.py -> buildlib.win-amd64-3.6osgeo
25
copying osgeo__init__.py -> buildlib.win-amd64-3.6osgeo
26
Fixing buildlib.win-amd64-3.6gdal.py buildlib.win-amd64-3.6ogr.py buildlib.win-amd64-3.6osr.py buildlib.win-amd64-3.6gdalconst.py buildlib.win-amd64-3.6gnm.py buildlib.win-amd64-3.6osgeogdal.py buildlib.win-amd64-3.6osgeogdalconst.py buildlib.win-amd64-3.6osgeogdalnumeric.py buildlib.win-amd64-3.6osgeogdal_array.py buildlib.win-amd64-3.6osgeognm.py buildlib.win-amd64-3.6osgeoogr.py buildlib.win-amd64-3.6osgeoosr.py buildlib.win-amd64-3.6osgeo__init__.py
27
Skipping optional fixer: ws_comma
28
Fixing buildlib.win-amd64-3.6gdal.py buildlib.win-amd64-3.6ogr.py buildlib.win-amd64-3.6osr.py buildlib.win-amd64-3.6gdalconst.py buildlib.win-amd64-3.6gnm.py buildlib.win-amd64-3.6osgeogdal.py buildlib.win-amd64-3.6osgeogdalconst.py buildlib.win-amd64-3.6osgeogdalnumeric.py buildlib.win-amd64-3.6osgeogdal_array.py buildlib.win-amd64-3.6osgeognm.py buildlib.win-amd64-3.6osgeoogr.py buildlib.win-amd64-3.6osgeoosr.py buildlib.win-amd64-3.6osgeo__init__.py
29
Skipping optional fixer: ws_comma
30
running build_ext
31
building 'osgeo._gdal' extension
32
creating buildtemp.win-amd64-3.6
33
creating buildtemp.win-amd64-3.6Release
34
creating buildtemp.win-amd64-3.6Releaseextensions
35
C:Program Files (x86)Microsoft Visual Studio2017BuildToolsVCToolsMSVC14.13.26128binHostX86x64cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -I../../port -I../../gcore -I../../alg -I../../ogr/ -I../../ogr/ogrsf_frmts -I../../gnm -I../../apps -Ic:usersanaconda3include -Ic:usersanaconda3include -I. "-IC:Program Files (x86)Microsoft Visual Studio2017BuildToolsVCToolsMSVC14.13.26128include" "-IC:Program Files (x86)Windows Kits10include10.0.16299.0ucrt" "-IC:Program Files (x86)Windows Kits10include10.0.16299.0shared" "-IC:Program Files (x86)Windows Kits10include10.0.16299.0um" "-IC:Program Files (x86)Windows Kits10include10.0.16299.0winrt" "-IC:Program Files (x86)Windows Kits10include10.0.16299.0cppwinrt" /EHsc /Tpextensions/gdal_wrap.cpp /Fobuildtemp.win-amd64-3.6Releaseextensions/gdal_wrap.obj
36
gdal_wrap.cpp
37
extensions/gdal_wrap.cpp(3168): fatal error C1083: Cannot open include file: 'cpl_port.h': No such file or directory
38
error: command 'C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.13.26128\bin\HostX86\x64\cl.exe' failed with exit status 2
39
Any ideas how to fix this? I just want use the ogr2ogr
in gdal to convert .shp to GeoJSON then to topojson.
Advertisement
Answer
I had the same problem and found the solution here: gdal-installation-error-using-pip
That is: download the wheel file and install from the command line.