Google App Engine SDK 错误 - "No Module named requests"

Google App Engine SDK ERROR- "No Module named requests"

我安装了 App Engine SDK,然后执行了 pip install requests 和 pip install requests-toolbelt(在 VENV 下)。当 运行 本地开发服务器中的应用程序时 - 我收到以下错误:

ERROR    2017-05-31 18:14:52,315 cgi.py:122] Traceback (most recent call last):
  File "/Users/assafshamia/Freebird/Techradar/dev/scraper.py", line 8, in <module>
    import requests
ImportError: No module named requests

我按照安装第 3 方库的步骤进行操作(appengine_config.py 并在 /lib 下安装请求)

这是怎么回事???

根据 docs,您需要将请求库代码添加到您的应用程序目录中。 pip install 不够。

You can include third party Python libraries with your application by putting the code in your application directory.

编辑:

此外:

The include path of the Python module includes your application's root directory, which is the directory containing the app.yaml file. Python modules that you create in your application's root directory are available using a path from the root. Don't forget to create the required init.py files in your sub-directories so that Python recognizes those sub-directories as packages.

我可以通过将以下代码添加到我的 Python 应用程序 (main.py) 来解决此问题,以便访问位于 /lib 的库:​​

import sys
sys.path.insert(0, 'lib')