简体   繁体   English

在Windows上使用Conda安装GDAL

[英]Installation of GDAL with Conda on Windows

I have Anaconda Python 3.6 on Windows 7. I frequently use GeoPandas and it worked fine. 我在Windows 7上安装了Anaconda Python 3.6。我经常使用GeoPandas,它运行良好。 Yesterday I tried to install rasterio and georasters, and they seemed to install fine using the suggested method 昨天我尝试安装rasterio和georasters,使用建议的方法似乎安装得很好

conda config --add channels conda-forge
conda install rasterio

Then installed georasters using 然后使用安装了georasters

conda install -c conda-forge georasters

And got a successfull installation message. 并获得了成功的安装消息。 When trying to import them they do not work - there is an error message on import rasterio or import georasters . 尝试导入它们时,它们不起作用- import rasterioimport georasters出现错误消息。 Digging into it, I found geopandas, fiona and GDAL were now also broken and after 1hr trying uninstalling/ installing packages with conda I'm not sure what is the problem and solution. 深入研究发现,geopandas,fiona和GDAL现在也坏了,尝试使用conda卸载/安装软件包1小时后,我不确定是什么问题和解决方案。 The root problem seems to be GDAL, but I'm not sure. 根本问题似乎是GDAL,但我不确定。

Importing GDAL gives the following error message 导入GDAL会出现以下错误消息

>>> import gdal
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python36_Anaconda3\lib\site-packages\gdal.py", line 2, in <module>
    from osgeo.gdal import deprecation_warn
  File "C:\Python36_Anaconda3\lib\site-packages\osgeo\__init__.py", line 25, in
<module>
    _gdal = swig_import_helper()
  File "C:\Python36_Anaconda3\lib\site-packages\osgeo\__init__.py", line 21, in
swig_import_helper
    _mod = imp.load_module('_gdal', fp, pathname, description)
  File "C:\Python36_Anaconda3\lib\imp.py", line 243, in load_module
    return load_dynamic(name, filename, file)
  File "C:\Python36_Anaconda3\lib\imp.py", line 343, in load_dynamic
    return _load(spec)
ImportError: DLL load failed: The specified module could not be found.

Does anybody know a fix or how to reinstall these packages cleanly? 有谁知道修复程序或如何干净地重新安装这些软件包?

Starting with the python environment that works fine, and installing the packages with the flag --no-update-dependencies allowed the packages to get installed and work with no problems. 从运行良好的python环境开始,并使用标志--no-update-dependencies安装软件包,这样软件包就可以安装并正常工作。 They may not be the most up to date versions, but they work. 它们可能不是最新版本,但它们可以工作。

conda install rasterio --no-update-dependencies
conda install georasters --no-update-dependencies

This may also be a solution for anyone trying to install packages that break your python environment. 对于任何试图安装破坏python环境的软件包的人来说,这也可能是一个解决方案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM