gdal 安装和运行在Ubuntu的精神抖擞的但我不能运行 gdal2tiles 因为我的错误:

Traceback (most recent call last):
  File "/usr/local/bin/gdal2tiles.py", line 42, in <module>
    import gdal
ImportError: No module named gdal

当我打开python和类型 import gdal 我得到的同样的错误。

set LD_LIBRARY_PATH (没有空间!) 要 /usr/local/lib 但它似乎没有作出任何区别。

看起来像蟒蛇不能找到 gdal.任何人都可以帮忙吗?

谢谢!

有帮助吗?

解决方案

Ith似乎是一个"蟒蛇的路径"问题。蟒蛇图书馆是看看行动在一定义的道路。尝试

import sys
sys.path

如果目录gdal.py 相关的文件不在此列,然后蟒蛇不能找到它。这是"诊断"的一部分。到解决的情况下,你有几种选择...他们所有铰链在知道规则其Python使用建立这条道路。

  • PYTHONPATH环境变可以改变,以包括所期望的路径
  • 蟒蛇可以开始从目录所需的图书馆所在。
  • sys.路径可以是动态的改变,与sys.路径。append("/SomePath/To/的mystuff")

唯一的地方,在那里我见过的规则建筑的sys.路径前所述,在"官方"蟒蛇的文件,是在 教程, 在第6.1.2
摘录:

modules are searched in the list of directories given by the variable sys.path
which is initialized from the directory containing the input script (or the 
current directory), PYTHONPATH and the installation- dependent default. This
allows Python programs that know what they’re doing to modify or replace the
module search path. Note that because the directory containing the script being
run is on the search path, it is important that the script not have the same name
as a standard module, or Python will attempt to load the script as a module when
that module is imported. This will generally be an error. See section
Standard Modules for more information.

其他提示

下面是教导如何安装和使用Python + GDAL,OGR和其他工具的链接。

希望其是有用的。

http://www.gis.usu.edu/~chrisg/python / 2009 /

您可能还需要检查GDAL维基致力于绑定到Python - GdalOgrInPython 其中在Linux和Windows平台上安装和使用进行了讨论。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top