Gdal will not import after several installs (Mac OSX)

萝らか妹 提交于 2019-12-11 09:49:30

问题


Using Macports,

I've tried to install: gdal, py27gdal, and gdal-grass. All so I can import gdal into python 2.7.2.

Neither have been successful.

When I type:

port list installed

I see the installed modules:

gdal-grass                     @1.4.3          gis/gdal-grass   
gdbm                           @1.8.3          databases/gdbm    
py27-gdal                      @1.7.1          python/py27-gdal

And when I run python to import the module:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named gdal

What am I doing wrong?


回答1:


Are you using the MacPorts python2.7? Try launching Python this way:

/opt/local/bin/python2.7



回答2:


I'm not 100% sure if this solves your problem, but gdal is in the osgeo namespace. So you should try importing gdal like this:

from osgeo import gdal

The gdal namespace itself is deprecated.



来源:https://stackoverflow.com/questions/7094749/gdal-will-not-import-after-several-installs-mac-osx

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!