[英]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.