问题
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