无法安装Python和GDAL(DLL加载失败)

发布于 11-07 12:30 字数 1178 浏览 3 评论 0原文

我正在尝试在我的 Windows 7 工作站上安装 GDAL 和 Python。

  • Python 版本:2.6.6
  • Gdal 1.8
  • (Visual Visual C++ Studio 2010 Express)

我按照 http://ucsb.pbworks.com/w/page/1936549/Using-GDAL-with-Python 并添加PYTHONPATH 和 GDAL_DATA 到我的系统环境变量。此外,我通过添加 GDAL 二进制文件文件夹修改了 PATH 变量。

我从以下位置下载的 GDAL Python 绑定: http://vbkto.dyndns.org/sdk/PackageList.aspx?file=release-1600-gdal-1-8-mapserver-5-6.zip

from osgeo import gdal”会导致以下错误消息:

Traceback (most recent call last):
  File "<pyshell#2>", line 1, in <module>
    from osgeo import gdal
  File "C:\Python26\lib\site-packages\osgeo\__init__.py", line 21, in <module>
    _gdal = swig_import_helper()
  File "C:\Python26\lib\site-packages\osgeo\__init__.py", line 17, in swig_import_helper
    _mod = imp.load_module('_gdal', fp, pathname, description)
ImportError: DLL load failed: Das angegebene Modul wurde nicht gefunden.

提前致谢, 马特维格

I am trying to install GDAL and Python on my Windows 7 workstation.

  • Python-version: 2.6.6
  • Gdal 1.8
  • (Visual Visual C++ Studio 2010 Express)

I followed the instructions at http://ucsb.pbworks.com/w/page/1936549/Using-GDAL-with-Python and added PYTHONPATH and the GDAL_DATA to my systems environment variables. Furthermore I modified my PATH variable by adding the GDAL binaries folder.

The GDAL Python bindings I downloaded from: http://vbkto.dyndns.org/sdk/PackageList.aspx?file=release-1600-gdal-1-8-mapserver-5-6.zip

"from osgeo import gdal" causes the following error-message:

Traceback (most recent call last):
  File "<pyshell#2>", line 1, in <module>
    from osgeo import gdal
  File "C:\Python26\lib\site-packages\osgeo\__init__.py", line 21, in <module>
    _gdal = swig_import_helper()
  File "C:\Python26\lib\site-packages\osgeo\__init__.py", line 17, in swig_import_helper
    _mod = imp.load_module('_gdal', fp, pathname, description)
ImportError: DLL load failed: Das angegebene Modul wurde nicht gefunden.

Thanks in advance,
Martwig

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

不奢求什么2024-11-14 12:30:31

要在 Windows 7 中从 python 成功加载 GDAL,我遵循以下步骤,这些步骤应该非常通用:

  1. 安装您选择的 python,我使用从官方网站下载的 v2.7.2 x64
  2. 从命令行运行 python 以确定用于的编译器版本构建 python (我的显示此消息:Python 2.7.2 (default, Jun 12 2011, 14:24:46) [MSC v.1500 64 bit (AMD64)] on win32
  3. 下载相应的 SDK通过此链接:http://www.gisinternals.com/release.php。为您的 python 选择正确的包(如果使用上述配置,则应选择 MSVC2008 x64 release 链接)。
  4. 从子页面下载以下内容:
    • GDAL 核心组件
    • Python 绑定
  5. 安装 GDAL 核心组件,将安装目录添加到路径中,并添加新的环境变量“GDAL_DATA”指向 GDAL 安装的数据子目录。
  6. 安装 python 绑定
  7. 现在你应该可以从它们中受益了:)

To successfully load GDAL from python in Windows 7, I follow these steps, which should be quite generic:

  1. Install python of your choosing, I used v2.7.2 x64 downloaded from the official website
  2. Run python from command line to determine the compiler version used to build python (mine shows this message: Python 2.7.2 (default, Jun 12 2011, 14:24:46) [MSC v.1500 64 bit (AMD64)] on win32)
  3. Download the corresponding SDK from this link: http://www.gisinternals.com/release.php. Select the correct package for your python (if using the above configuration, then MSVC2008 x64 release link should be selected).
  4. From the subpage, download the following:
    • GDAL core components
    • Python bindings
  5. Install GDAL core components, add the installation dir to path, and add new environment variable 'GDAL_DATA' pointing to data subdirectory of GDAL installation.
  6. Install python bindings
  7. You should be profiting from them by now :)
烟酒忠诚2024-11-14 12:30:31

一步一步的过程很棒。但我也有同样的问题。

这是因为我的 PATH 变量具有使用相同名称的 dll 的其他路径。如果将 c:\program files\gdal 放在 PATH 中其他路径之前,它就可以正常工作!

The step by step procedure is great. But I had the same issue.

This was caused because my PATH variable has other paths where a same named dll was used. If you put the c:\program files\gdal before the other paths in PATH, it works fine!

心房的律动2024-11-14 12:30:31

在从上述答案中搜索并执行了许多步骤但没有结果后,我终于使用 Python 扩展包的非官方 Windows 二进制文件

只需向下滚动页面并找到 GDAL 部分并获取您的版本安装程序。

After searching and making many steps from the above answers with no result, i finally got install to Win7 gdal by using the installer from Unofficial Windows Binaries for Python Extension Packages

Just scroll down the page and find GDAL section and get your version installer.

神回复2024-11-14 12:30:31

I successfully installed gdal on 32 bit Windows from here: http://www.lfd.uci.edu/~gohlke/pythonlibs/#gdal. I solved the "side by side" DLL error by installing this Microsoft Visual C++ 2008 Service Pack 1 Redistributable Package MFC Security Update.

堇年纸鸢2024-11-14 12:30:31

适用于 python 3.4、v.1600、Windows 10 的解决方案

确保您的 python 版本是什么,

python -v
Python 3.4.2 (v3.4.2:ab2c023a9432, Oct  6 2014, 22:15:05) [MSC v.1600 32 bit (Intel)] on win32

以便您在此处看到它是 v.1600 和 32 位。然后转到此处

http://www. gisinternals.com/query.html?content=filelist&file=release-1600-gdal-mapserver.zip

并下载:

  1. gdal-201-1600-core.msi
  2. GDAL-2.1。 0.win32-py3.4.msi
  3. 这些 msi 文件

安装 然后确保您没有在任何地方安装 OSGEO4W(如果安装了该文件夹,只需完全删除该文件夹即可)。

b.去编辑你的环境变量并包含在 PATH 中:
C:\Program Files (x86)\GDAL;
(包含在开头!)

c.重新启动你的 python / virtualenv 和 IDE。

此时您应该让一切正常工作

还有 python 2.7、3.3、3.1 和其他版本的绑定 http://www.gisinternals.com/development.php

solution for python 3.4, v.1600, Windows 10

make sure what your python version is

python -v
Python 3.4.2 (v3.4.2:ab2c023a9432, Oct  6 2014, 22:15:05) [MSC v.1600 32 bit (Intel)] on win32

so here you see that it's v.1600 and 32 bit. Then go here

http://www.gisinternals.com/query.html?content=filelist&file=release-1600-gdal-mapserver.zip

and download:

  1. gdal-201-1600-core.msi
  2. GDAL-2.1.0.win32-py3.4.msi
  3. Install these msi files

a. then make sure you DON'T GET OSGEO4W installed anywhere (just remove the folder completely if you got it installed).

b. go and edit your environment vars and include in PATH:
C:\Program Files (x86)\GDAL;
(include in the beginning!)

c. restart your python / virtualenv and IDE.

You should get everything working at this point

there are also bindings for python 2.7, 3.3, 3.1, other releases http://www.gisinternals.com/development.php

音盲2024-11-14 12:30:31

试试这个:

  • 将 GDAL 核心文件夹路径添加到 PYTHONPATH 变量中
  • 如果在 Eclipse 中使用 PyDev,请使用 PyDev 解释器部分强制全局 PATH 变量包含它。您还可以在此处设置 PYTHONPATH。

这样做后我摆脱了这个错误。有趣的是,以前在 Python 交互式 shell 中调用抛出导入异常的行是有效的。也许我们都在使用 PyDev。

Try this:

  • Add the GDAL core folder path to your PYTHONPATH variable
  • If using PyDev in Eclipse, force the global PATH variable to be include it using the PyDev interpreters section. You can also set PYTHONPATH here.

I got rid of this error after doing this. Funny thing was, calling that line that throws the import exception in a Python interactive shell worked before. Maybe we're all using PyDev.

小矜持2024-11-14 12:30:31

我发现我需要将环境变量 PATH、GDAL_DATA 和 GDAL_DRIVER_PATH (所有三个)添加到系统变量而不是“您的用户名”的用户变量。

I found that I needed to add the environment variables PATH, GDAL_DATA and GDAL_DRIVER_PATH (all three of them) to System variables NOT user variables for "your username".

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文