我需要导入 osgeo.ogr
模块到 virtualenv
python 程序。
全局 python 有这个模块:
user@ubuntu:~/$ python
Python 2.7.8 (default, Oct 20 2014, 15:05:19)
[GCC 4.9.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import osgeo
>>>
但是进入 virtualenv(没有 --no-site-packages):
user@ubuntu:~$ temp/bin/python
Python 2.7.8 (default, Oct 20 2014, 15:05:19)
[GCC 4.9.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import osgeo
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named osgeo
这种行为的原因是什么?
最佳答案
可以用这个解决
pip install --global-option=build_ext --global-option="-I/usr/include/gdal" GDAL==`gdal-config --version`
关于python - 没有名为 osgeo.ogr 的模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29852857/