首页 > 解决方案 > 在 GCP 应用程序机器上安装 s2geometry 时遇到问题

问题描述

嘿大家,

我最近开始在自己的计算机和环境上使用s2geometry ,一切都很棒。问题是我现在正试图在谷歌云 App Engine 上使用我的代码,但在安装 s2geometry 时遇到了一个我不知道如何解决的错误。

这是我所做的:

mkdir s2geo
cd s2geo
git clone https://github.com/google/s2geometry.git
cd s2geometry
mkdir build
cd build
cmake \
            -DGTEST_ROOT=/home/path_to_googletest \
            -DPYTHON_EXECUTABLE=/usr/bin/python3 \
            -DPYTHON_INCLUDE_DIR=/usr/include/python3.7m \
            -DPYTHON_LIBRARY=/usr/lib/x86_64-linux-gnu/libpython3.7m.so ..
sudo make 
sudo make install

起初我在做的时候遇到了一些问题,因为 python 可执行文件是 python2 因此所有的标志。使用这些标志,我在这样做时没有遇到任何问题,但是每当我尝试导入 s2 时,我都会遇到以下错误:

  File "/usr/lib/python3.7/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
ImportError: dynamic module does not define module export function (PyInit__pywraps2)

据我了解,这是一个错误,因为 Python 正在从已编译的 *.so 文件而不是 *.py 文件加载模块。该错误是由链接到 Python 2 库而不是 Python 3 库的 *.so 文件引起的。或者至少这是我在这里找到的:https ://github.com/pytorch/ELF/issues/98

所以我的问题是:我做错了什么?Python 2 是默认 Python 解释器的问题吗?我必须提到什么标志才能正确安装模块。

非常感谢。

标签: python-3.xubuntugoogle-cloud-platform

解决方案


推荐阅读