requests_toolbelt.exceptions.VersionMismatchError:工具带至少需要安装Requests 2.10.0。发现版本2.6.0

时间:2016-09-21 05:09:21

标签: python google-app-engine

我需要在我的应用中使用请求。我按照here所描述的发出HTTP(S)请求的说明进行了操作。

我在代码中调用request_toolbels就像这样

from flask import Flask
from routes import configure_blueprints
from modules.filters import init_babel
import requests
import requests_toolbelt.adapters.appengine


def create_app():
    """Create the Flask App"""
    v = requests.__version__

    requests_toolbelt.adapters.appengine.monkeypatch()
    app = Flask(__name__)
    configure_blueprints(app)
    init_babel(app)
    return app

当我调试v的值是2.6.0时。但我确定我已经安装了请求2.11.1

运行单元测试时出现以下错误。

C:\Python27\python.exe "C:\Program Files (x86)\JetBrains\PyCharm 2016.2.3\helpers\pycharm\utrunner.py" C:\Code\zion-alpha\Tests\ZionTestSuite.py true
Testing started at 3:04 PM ...
C:\Code\zion-alpha\Tests\ZionTestSuite.py:1: RuntimeWarning: Parent module 'Tests' not found while handling absolute import
  import unittest2
C:\Code\zion-alpha\Tests\ZionTestSuite.py:2: RuntimeWarning: Parent module 'Tests' not found while handling absolute import
  from Tests.TestCases.handler_tests import AppTest
Traceback (most recent call last):
  File "C:\Program Files (x86)\JetBrains\PyCharm 2016.2.3\helpers\pycharm\utrunner.py", line 153, in <module>
    modules = [loadSource(a[0])]
  File "C:\Program Files (x86)\JetBrains\PyCharm 2016.2.3\helpers\pycharm\utrunner.py", line 65, in loadSource
    module = imp.load_source(moduleName, fileName)
  File "C:\Code\zion-alpha\Tests\ZionTestSuite.py", line 2, in <module>
    from Tests.TestCases.handler_tests import AppTest
  File "C:\Code\zion-alpha\Tests\TestCases\handler_tests.py", line 1, in <module>
    from Tests.TestCases.Base.base_test import TestBase, app
  File "C:\Code\zion-alpha\Tests\TestCases\Base\base_test.py", line 12, in <module>
    app = TestApp(create_app())
  File "C:\Code\zion-alpha\app\__init__.py", line 12, in create_app
    requests_toolbelt.adapters.appengine.monkeypatch()
  File "C:\Code\zion-alpha\lib\requests_toolbelt\adapters\appengine.py", line 133, in monkeypatch
    _check_version()
  File "C:\Code\zion-alpha\lib\requests_toolbelt\adapters\appengine.py", line 145, in _check_version
    requests.__version__
requests_toolbelt.exceptions.VersionMismatchError: The toolbelt requires at least Requests 2.10.0 to be installed. Version 2.6.0 was found instead.

2 个答案:

答案 0 :(得分:1)

这是因为appengine sdk有自己的请求版本。你需要安装sdk 1.9.49来获取请求2.10 旧版本的appengine sdk登陆请求2.6.0

您在lib目录中安装的请求版本无关紧要。 Appengine始终默认为其自己的请求版本。

答案 1 :(得分:0)

pip install requests==2.10.0将解决此问题