在Google App Engine中安装Unirest Python模块

0 投票
1 回答
749 浏览
提问于 2025-04-18 05:38

你好,我是GAE和Python的新手。我正在尝试用Python在GAE上创建一个小型网页应用。我打算在应用中使用Unirest模块。

我按照这篇文章中的说明操作,但出现了以下错误。

没有名为poster.encode的模块

我该如何在GAE上成功安装Unirest呢?

谢谢

1 个回答

0

在你的 main.py 文件里添加 import sys 这行代码,然后再加上下面这些内容。

# inject './lib' dir in the path so that we can simply do "import ndb" or whatever there's in the app lib dir.
if 'lib' not in sys.path:
    sys.path[0:0] = ['lib']

在你项目的根目录下创建一个 lib 文件夹,然后把 unirest 文件夹复制到这个 lib 文件夹里。

现在你就可以导入 unirest 并使用你的库了。

不过,为什么不使用 Google App Engine 提供的标准方法和库呢?

撰写回答