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

时间:2022-01-07 21:07:14

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

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

  • Python-version: 2.6.6
  • python版本:2.6.6
  • Gdal 1.8
  • Gdal 1.8
  • (Visual Visual C++ Studio 2010 Express)
  • (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.

我遵循了http://ucsb.pbworks.com/w/page/1936549/usinggdal -with- python的指示,并将PYTHONPATH和GDAL_DATA添加到我的系统环境变量中。此外,我通过添加GDAL二进制文件夹来修改PATH变量。

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

我下载的GDAL Python绑定是:http://vbkto.dyndns.org/sdk/packagelist .aspx? filerele- 1600-gdal-1-8-mapserver-5-6.zip。

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

“从osgeo导入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.

Thanks in advance, Martwig

谢谢你提前,Martwig

7 个解决方案

#1


20  

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

为了在Windows 7中成功地从python加载GDAL,我遵循以下步骤,这应该是非常通用的:

  1. Install python of your choosing, I used v2.7.2 x64 downloaded from the official website
  2. 安装您选择的python,我使用了从官方网站下载的v2.7.2 x64。
  3. 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)
  4. 从命令行运行python来确定用于构建python的编译器版本(我的显示:python 2.7.2(默认,2011年6月12日,14:24:46)[MSC v。150064位(AMD64)]在win32上
  5. 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).
  6. 从这个链接下载相应的SDK: http://www.gisinternals.com/release.php。为您的python选择正确的包(如果使用上述配置,则应该选择MSVC2008 x64发布链接)。
  7. From the subpage, download the following:
    • GDAL core components
    • GDAL核心组件
    • Python bindings
    • Python绑定
  8. 从子页面下载以下内容:GDAL核心组件Python绑定。
  9. Install GDAL core components, add the installation dir to path, and add new environment variable 'GDAL_DATA' pointing to data subdirectory of GDAL installation.
  10. 安装GDAL核心组件,将安装目录添加到path中,并添加新的环境变量“GDAL_DATA”指向GDAL安装的数据子目录。
  11. Install python bindings
  12. 安装python绑定
  13. You should be profiting from them by now :)
  14. 你现在应该从他们身上获利:

#2


10  

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!

这是因为我的PATH变量有其他路径,其中使用了相同的命名dll。如果你把c:\程序文件\gdal在路径的其他路径之前,它工作的很好!

#3


4  

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

在搜索并从上面的答案中进行了许多步骤之后,我最终得到了Win7 gdal的安装,它使用的是来自于Windows二进制文件的Windows二进制文件的安装程序。

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

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

#4


2  

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.

我成功地在32位窗口中安装了gdal: http://www.lfd.uci.edu/~gohlke/pythonlibs/#gdal。我通过安装这个Microsoft Visual c++ 2008 Service Pack 1再分发包MFC安全更新,解决了“side by side”DLL错误。

#5


2  

solution for python 3.4, v.1600, Windows 10

对python 3.4, v的解决方案。1600年,Windows 10

make sure what your python version is

确保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

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

这是v。1600年,32位。然后在这里

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

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

and download:

和下载:

  1. gdal-201-1600-core.msi
  2. gdal - 201 - 1600 - core.msi
  3. GDAL-2.1.0.win32-py3.4.msi
  4. GDAL-2.1.0.win32-py3.4.msi
  5. Install these msi files
  6. 安装这些msi文件

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

然后确保你没有安装OSGEO4W(如果你安装了它,就把文件夹完全移除)。

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

b去编辑环境var和包含在路径:C:\Program Files (x86)\ GDAL;(包括一开始!)

c. restart your python / virtualenv and IDE.

重新启动您的python / virtualenv和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

也有针对python 2.7、3.3、3.1的绑定,其他的版本有http://www.gisinternals.com/development.php。

#6


0  

Try this:

试试这个:

  • Add the GDAL core folder path to your PYTHONPATH variable
  • 将GDAL核心文件夹路径添加到您的PYTHONPATH变量中。
  • 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.
  • 如果在Eclipse中使用PyDev,则使用PyDev解释器部分强制将全局路径变量包括在内。你也可以在这里设置PYTHONPATH。

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.

在做了这个之后,我去掉了这个错误。有趣的是,调用那条在Python交互shell中抛出导入异常的行以前工作过。也许我们都在使用PyDev。

#7


0  

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".

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

#1


20  

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

为了在Windows 7中成功地从python加载GDAL,我遵循以下步骤,这应该是非常通用的:

  1. Install python of your choosing, I used v2.7.2 x64 downloaded from the official website
  2. 安装您选择的python,我使用了从官方网站下载的v2.7.2 x64。
  3. 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)
  4. 从命令行运行python来确定用于构建python的编译器版本(我的显示:python 2.7.2(默认,2011年6月12日,14:24:46)[MSC v。150064位(AMD64)]在win32上
  5. 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).
  6. 从这个链接下载相应的SDK: http://www.gisinternals.com/release.php。为您的python选择正确的包(如果使用上述配置,则应该选择MSVC2008 x64发布链接)。
  7. From the subpage, download the following:
    • GDAL core components
    • GDAL核心组件
    • Python bindings
    • Python绑定
  8. 从子页面下载以下内容:GDAL核心组件Python绑定。
  9. Install GDAL core components, add the installation dir to path, and add new environment variable 'GDAL_DATA' pointing to data subdirectory of GDAL installation.
  10. 安装GDAL核心组件,将安装目录添加到path中,并添加新的环境变量“GDAL_DATA”指向GDAL安装的数据子目录。
  11. Install python bindings
  12. 安装python绑定
  13. You should be profiting from them by now :)
  14. 你现在应该从他们身上获利:

#2


10  

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!

这是因为我的PATH变量有其他路径,其中使用了相同的命名dll。如果你把c:\程序文件\gdal在路径的其他路径之前,它工作的很好!

#3


4  

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

在搜索并从上面的答案中进行了许多步骤之后,我最终得到了Win7 gdal的安装,它使用的是来自于Windows二进制文件的Windows二进制文件的安装程序。

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

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

#4


2  

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.

我成功地在32位窗口中安装了gdal: http://www.lfd.uci.edu/~gohlke/pythonlibs/#gdal。我通过安装这个Microsoft Visual c++ 2008 Service Pack 1再分发包MFC安全更新,解决了“side by side”DLL错误。

#5


2  

solution for python 3.4, v.1600, Windows 10

对python 3.4, v的解决方案。1600年,Windows 10

make sure what your python version is

确保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

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

这是v。1600年,32位。然后在这里

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

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

and download:

和下载:

  1. gdal-201-1600-core.msi
  2. gdal - 201 - 1600 - core.msi
  3. GDAL-2.1.0.win32-py3.4.msi
  4. GDAL-2.1.0.win32-py3.4.msi
  5. Install these msi files
  6. 安装这些msi文件

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

然后确保你没有安装OSGEO4W(如果你安装了它,就把文件夹完全移除)。

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

b去编辑环境var和包含在路径:C:\Program Files (x86)\ GDAL;(包括一开始!)

c. restart your python / virtualenv and IDE.

重新启动您的python / virtualenv和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

也有针对python 2.7、3.3、3.1的绑定,其他的版本有http://www.gisinternals.com/development.php。

#6


0  

Try this:

试试这个:

  • Add the GDAL core folder path to your PYTHONPATH variable
  • 将GDAL核心文件夹路径添加到您的PYTHONPATH变量中。
  • 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.
  • 如果在Eclipse中使用PyDev,则使用PyDev解释器部分强制将全局路径变量包括在内。你也可以在这里设置PYTHONPATH。

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.

在做了这个之后,我去掉了这个错误。有趣的是,调用那条在Python交互shell中抛出导入异常的行以前工作过。也许我们都在使用PyDev。

#7


0  

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".

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