如何在PyPy中使用GDAL?


14

我正在尝试使用pypy优化我的python代码。虽然我能够导入大多数库并成功运行,但是我却无法导入GDAL库。在Python 2.7中导入时,相同的库运行良好。

我尝试将GDAL位置添加到PYTHONPATH,甚至尝试将GDAL Python绑定下载到PyPy目录,但是pypy不想识别GDAL,并且出现以下错误。

Traceback (most recent call last):

  File "app_main.py", line 51, in run_toplevel

  File "ImportENC-P.py", line 50, in <module>

    from osgeo import gdal, ogr, osr

  File "B:\PYPY\site-packages\osgeo\__init__.py", line 21, in <module>

    _gdal = swig_import_helper()

  File "B:\PYPY\site-packages\osgeo\__init__.py", line 13, in swig_import_helper

    import _gdal

ImportError: No module named _gdal

Answers:


14

Pypy 与SWIG不兼容(另请参见StackOverflow中的此答案),这是GDAL的C绑定用于与Python编译器通信的方式。除非您可以花时间用C-Types重写GDAL Python绑定(否则我不太可能),否则这不是一个小小的难题。

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.