gpt4 book ai didi

python - 导入错误 : Python + GDAL - OSGeo4W installation

转载 作者:行者123 更新时间:2023-11-28 22:02:52 24 4
gpt4 key购买 nike

我已经为 Windows 安装了最新的 OSGeo4W 编译,我想使用各种可用的 GDAL 工具。当我打开 OSGeo4W command shell 时,输入 Python 并写入

> from osgeo import gdal

我收到以下错误:

> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> File "C:\OSGeo4W\apps\Python27\lib\site-packages\osgeo\__init__.py", line 21,
> in <module>
> _gdal = swig_import_helper()
> File "C:\OSGeo4W\apps\Python27\lib\site-packages\osgeo\__init__.py", line 17,
> in swig_import_helper
> _mod = imp.load_module('_gdal', fp, pathname, description)
> ImportError: DLL load failed: The operating system cannot run %1.

我的PATH 包含以下 OSGeo4W 条目:

> C:\OSGeo4W\bin
> C:\OSGeo4W\\apps\msys\bin
> C:\OSGeo4W\\apps\Python27\Scripts

根据我在网上看到的信息,这个错误可能与不兼容的版本有关。我假设 OSGeo4W 包被编译为按原样工作,因此它可能是以前安装在我的计算机上的其他版本或干扰的残留物。但我不知道如何确定干扰因素以及该信息的存储位置。

我该怎么做才能解决这个问题?

最佳答案

当安装了另一个版本的 python 时会出现此问题。

我发现当我在 PATH 变量的开头添加目录路径到 C:\OSGeo4W\bin 并通过 OSGEO4W 运行 python shell,我能够导入 gdal 库。

关于python - 导入错误 : Python + GDAL - OSGeo4W installation,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10481138/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com