首页 > 解决方案 > Google App Engine rtree Python 模块安装

问题描述

Google App Engine,不包括 libspatialindex,因此我无法安装 rtree python 模块,即使它在 requirements.txt 中,

它在部署应用程序时出现以下错误。(应用程序在本地运行良好。)如何在 python 标准谷歌应用程序引擎环境中安装特定的库?或者我如何要求他们这样做?

Collecting rtree
  Downloading Rtree-0.9.4.tar.gz (62 kB)
    ERROR: Command errored out with exit status 1:
     command: /opt/python3.8/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-hl9513g_/rtree/setup.py'"'"'; __file__='"'"'/tmp/pip-install-hl9513g_/rtree/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-0tyv4fij
         cwd: /tmp/pip-install-hl9513g_/rtree/
    Complete output (15 lines):
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-install-hl9513g_/rtree/setup.py", line 3, in <module>
        import rtree
      File "/tmp/pip-install-hl9513g_/rtree/rtree/__init__.py", line 1, in <module>
        from .index import Rtree
      File "/tmp/pip-install-hl9513g_/rtree/rtree/index.py", line 6, in <module>
        from . import core
      File "/tmp/pip-install-hl9513g_/rtree/rtree/core.py", line 143, in <module>
        rt.Error_GetLastErrorNum.restype = ctypes.c_int
      File "/opt/python3.8/lib/python3.8/ctypes/__init__.py", line 386, in __getattr__
        func = self.__getitem__(name)
      File "/opt/python3.8/lib/python3.8/ctypes/__init__.py", line 391, in __getitem__
        func = self._FuncPtr((name_or_ordinal, self))
    AttributeError: /opt/python3.8/bin/python3: undefined symbol: Error_GetLastErrorNum
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

标签: pythonpython-3.xgoogle-app-engine

解决方案


您将需要使用具有自定义运行时的灵活环境来利用标准环境中未预安装的软件包。

要安装 libspatialindex,请将其添加到 Dockerfile:

sudo apt-get update -y
sudo apt-get install -y libspatialindex-dev

推荐阅读