过去一个小时,我一直在尝试在Windows上的Python 3.6.5(64位)上安装GDAL,但没有任何效果.
I've been trying to install GDAL on Python 3.6.5 (64-bit) on Windows for the past hour, and nothing works.
我已经访问了一些关于SO的问题,观看了有关YT的视频,但是这些问题都不适合我的情况(这没什么特别的.)
I've visited some questions on SO, watched a video on YT, but none of them applies to my situation (which there's nothing special about it).
有人可以提供循序渐进的解决方案,最好是经过测试的解决方案,这样我才能弄清楚我到底在做错什么?
Can someone provide a step-by-step solution, preferably a tested one, so I can figure out what exactly I'm doing wrong?
如有必要,我愿意提供任何操作系统设置信息/屏幕截图.
I'm willing provide any OS setting info/screenshot if necessary.
更新:我正在尝试安装GDAL,以将TIF(16位)文件转换为JPG或PNG.尽管我设法用第二种方法(第二次尝试)安装了GDAL,但是我却不能使用gdal_translate.因此,并非每个GDAL lib/version都对我有用.
Update: I'm trying to install GDAL to convert TIF (16-bit) files to JPG or PNG. Although I managed to install GDAL with the second method (at second try), I could not use gdal_translate. So not every GDAL lib/version works for me.
第一种方法:
-
GDAL 2.3.0 (建议此处)
- 依赖项:
- libgdal(2.3.0或更高版本)和头文件(gdal-devel)(在哪里/如何获得此文件?)
- numpy (1.0.0或更高版本)和头文件(numpy-devel)
- Dependencies:
- libgdal (2.3.0 or greater) and header files (gdal-devel) (where/how do I get this?)
- numpy (1.0.0 or greater) and header files (numpy-devel)
需要"GDAL Windows二进制文件". Google搜索使我想到了这一点: DownloadingGdalBinaries – GDAL
Requires "GDAL Windows Binaries". A Google search led me to this: DownloadingGdalBinaries – GDAL
- 尝试过 GISInternals -> 发布-> 版本1911-x64-gdal-2-3-0-mapserver-7-0-7
- 下载了"gdal-203-1911-x64-core.msi"和"GDAL-2.3.0.win-amd64-py3.4.msi". (最新版本适用于python 3.4吗?)
- 已将"gdal-203-1911-x64-core.msi"安装到"C:\Program Files\GDAL".
-
在自述文件中说
- Tried GISInternals -> Releases -> release-1911-x64-gdal-2-3-0-mapserver-7-0-7
- Downloaded "gdal-203-1911-x64-core.msi" and "GDAL-2.3.0.win-amd64-py3.4.msi". (The latest release is for python 3.4?)
- Installed "gdal-203-1911-x64-core.msi" to "C:\Program Files\GDAL".
In README, it says
将安装目录bin文件夹添加到系统PATH ...
Add the installation directory bin folder to your system PATH...
C:\ gdalwin32-1.7 \ bin
C:\gdalwin32-1.7\bin
"C:\Program Files\GDAL"中没有"bin"文件夹. GDAL目录中的文件夹:"csharp","gdal-data","gdalplugins","license","projlib".那...?
There is no "bin" folder in "C:\Program Files\GDAL". Folders in GDAL dir: "csharp", "gdal-data", "gdalplugins", "license", "projlib". So ...?
我什至不打算完成此操作,因为它似乎已经过时了(我已经通过电子邮件将其描述告知了作者,因此希望它可以解决).我遵循了其他步骤,但是显然没有用.随时尝试.
I'm not even going to finish this because it seems outdated (I've emailed it's author about the description, so I hope it gets fixed). I followed the other steps, but it didn't work, obviously. Feel free to try it out.
第二种方法:
-
Gohlke Pythonlibs (建议此处)
- 下载的"GDAL-2.2.4-cp36-cp36m-win_amd64.whl"
-
在页面顶部,它说(我可能在第一次尝试中就错过了)
- Downloaded "GDAL-2.2.4-cp36-cp36m-win_amd64.whl"
At the top of the page, it says (I probably missed this in the first try)
许多二进制文件依赖于numpy-1.14 + mkl和...
Many binaries depend on numpy-1.14+mkl and ...
所以我已经下载了"numpy-1.14.4+mkl-cp36-cp36m-win_amd64.whl"(在同一页面中)
So I've downloaded "numpy-1.14.4+mkl-cp36-cp36m-win_amd64.whl" (it's in the same page)
已安装它们:
pip install numpy-1.14.4+mkl-cp36-cp36m-win_amd64.whl
pip install GDAL-2.2.4-cp36-cp36m-win_amd64.whl
并且有效(尽管使用gdal_translate时我丢失了dll(ogr_FileGDB)错误,所以不使用它)
and it worked (though I'm getting missing dll (ogr_FileGDB) error when using gdal_translate, so not using this)
我将使用尝试的方法对此进行更新.
I'll be updating this with the methods I've tried.
推荐答案conda-forge的预构建GDAL版本在Windows 64位python 3.6.5上非常有用
The prebuild GDAL version from conda-forge works great on windows 64 bit python 3.6.5
您可以安装 Anaconda (或迷你康达)
安装Anaconda后,我通常使用Anaconda提示符,而不是常规的Windows命令提示符.
After installing Anaconda, I usually use the Anaconda prompt instead of the regular windows command prompt.
(可选)如果您想在特定环境中隔离它
我建议在anaconda中使用环境,因此创建一些环境 像这样
I would recomend using environments with anaconda so create some environment like this
conda create --name gdal_env python=3.6.5
activate gdal_env
环境不是必需的,因此您可以跳过此步骤并继续安装gdal.
Environments are not required, so you can skip this step and continue to installing gdal.
安装gdal
conda install -c conda-forge gdal
我发现conda-forge是(到目前为止)在Windows上安装GDAL的最简单方法.如果由于某种原因您需要使用另一个python发行版,我也发现预编译二进制文件也可以从这里正常工作 www.lfd.uci.edu/~gohlke/pythonlibs/(如果您遵循本指南
I have found conda-forge to be the (by far) easiest way to install GDAL on windows. If for some reason you are required to use another python distribution, i have found the prebuild binaries from here to work fine too www.lfd.uci.edu/~gohlke/pythonlibs/ if you follow this guide
更多推荐
Python 3.6.5(64位)上的GDAL
发布评论