简体   繁体   English

PyCharm 中的光栅和 gdal DLL 加载失败

[英]rasterio and gdal DLL load fail in PyCharm

I have a conda environment with rasterio installed and a whole load of other libraries, including gdal.我有一个安装了 rasterio 的 conda 环境和一整套其他库,包括 gdal。

When I do:当我做:

import rasterio

on jupyter notebook, it loads fine and I can utilise it's methods etc..在 jupyter 笔记本上,它加载得很好,我可以利用它的方法等。

When I do exactly the same thing on PyCharm, with the same environment and interpreter, I can the following error:当我在 PyCharm 上用相同的环境和解释器做完全相同的事情时,我可能会出现以下错误:

from rasterio._base import gdal_version
ImportError: DLL load failed: The specified module could not be found.

I'm struggling to understand why this is the case, as it loads fine in jupter notebook.我很难理解为什么会这样,因为它在 jupter 笔记本中加载良好。

I encountered the same problem as you and has finished solving it.我遇到了和你一样的问题,已经解决了。

First, You need to ensure that gdal version is still 2.x.首先,您需要确保 gdal 版本仍然是 2.x。 If no, just remove it.如果没有,只需将其删除。

conda remove rasterio gdal -y

then reinstall gdal with specifying the installation version:然后指定安装版本重新安装gdal:

conda install rasterio gdal=2 -y

Then, you need add GDAL_DATA which containing a gcs.csv file to environment, for me in Windows:然后,你需要添加GDAL_DATA其中包含gcs.csv在Windows文件中的环境,对我来说:

setx /m GDAL_DATA C:\Users\Admin\AppData\Local\ESRI\conda\envs\python3\Library\share\gdal

reboot your computer, and import gdal before importing rasterio:重新启动计算机,并在导入光栅之前导入 gdal:

In [1]: import rasterio
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-1-350e27267e59> in <module>
----> 1 import rasterio

~\AppData\Local\ESRI\conda\envs\python3\lib\site-packages\rasterio\__init__.py in <module>
     20             pass
     21
---> 22 from rasterio._base import gdal_version
     23 from rasterio.drivers import is_blacklisted
     24 from rasterio.dtypes import (

ImportError: DLL load failed: 找不到指定的模块。

In [2]: from osgeo import gdal

In [3]: import rasterio

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

相关问题 重采样图像光栅/gdal,Python - Resample image rasterio/gdal, Python DLL加载失败:无法在Windows上使用GDAL - DLL load failed: Unable to use GDAL on windows 为什么当我通过 rasterio 或 gdal 加载 NDVI 图像时所有数据都是 Nan - Why all the data is Nan when I load NDVI image by rasterio or gdal 无法安装Python和GDAL(DLL加载失败) - Unable to install Python and GDAL (DLL load failed) GDAL 的 GetProjection() 和 GetGeoTransform() 的 Rasterio 等价物? - Rasterio equivalent for GDAL's GetProjection() and GetGeoTransform()? 使用conda在Windows上安装Gdal python库(DLL加载失败) - Installing gdal python library on windows using conda (DLL load failed) GDAL安装->导入错误:DLL加载失败:找不到指定的程序 - GDAL Installation -> ImportError: DLL load failed: The specified procedure could not be found Python Zbar DLL加载失败 - Python Zbar DLL load fail 修复“DLL加载失败:找不到指定的模块。” python 中用于导入光栅的错误 - Fixing "DLL load failed: The specified module could not be found." error in python for importing rasterio 使用 pyinstaller 将“.py 文件”(具有“导入光栅”)转换为“.exe 文件”时出现“导入错误:DLL 加载失败” - "Import Error: DLL load failed" while converting ".py file" (having "import rasterio") to ".exe file" using pyinstaller
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM