AttributeError:模块“tornado”没有属性“curl\u httpclient”

2024-06-16 11:21:46 发布

您现在位置:Python中文网/ 问答频道 /正文

我看到这个错误多次出现,似乎只是在使用python3时失败了。我发现nose detecthttp在引擎盖下使用vcrpy。这是出现导入错误的一种方式。我们使用的tornado、vcrpy和nose detecthttp版本包括:

Package                                                        Version
-------------------------------------------------------------- -----------                                                                                                                      
nose-detect-leaky-state                                        0.0.7
nose-detecthttp                                                1.2.1
tornado                                                        4.5
tornado-cors                                                   0.6.0                                       
vcrpy                                                          4.0.2                          
viivakoodi                                                     0.8.0
wcwidth                                                        0.2.4
websocket-client                                               0.58.0
Werkzeug                                                       0.15.0
wheel                                                          0.34.2
wrapt                                                          1.10.10
XML2Dict                                                       0.2.2
xmltodict                                                      0.12.0
yamllint                                                       1.19.0
yarl                                                           1.3.0
zipp                                                           0.6.0

这是错误的堆栈跟踪

item = <TestCaseFunction test_twilio_exception_is_not_reraised_if_twilio_raises_403_exception>
       

       

       @pytest.hookimpl(hookwrapper=True)
       

       def pytest_runtest_call(item):
       

       enabled = item.config._detecthttp_enabled
       

       if enabled:
       

       cassette_name = "%s.yaml" % item
       

       cassette_manager = vcr.use_cassette(
       

       cassette_name,
       

       serializer='yaml',
       

       record_mode='once',
       

       ignore_localhost=True,
       

       ignore_hosts=item.config._detecthttp_ignored_hosts)
       

       

       >           cassette = cassette_manager.__enter__()
       

       

       cassette_manager = <vcr.cassette.CassetteContextDecorator object at 0x7fdaf6e9d6d8>
       

       cassette_name = '<TestCaseFunction test_twilio_exception_is_not_reraised_if_twilio_raises_403_exception>.yaml'
       

       enabled    = True
       

       item       = <TestCaseFunction test_twilio_exception_is_not_reraised_if_twilio_raises_403_exception>
       

       

       venv/lib/python3.5/site-packages/detecthttp/pytest.py:63:
       

       _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
       

       venv/lib/python3.5/site-packages/vcr/cassette.py:87: in __enter__
       

       return next(self.__finish)
       

       venv/lib/python3.5/site-packages/vcr/cassette.py:60: in _patch_generator
       

       for patcher in CassettePatcherBuilder(cassette).build():
       

       venv/lib/python3.5/site-packages/vcr/patch.py:123: in _build_patchers_from_mock_triples
       

       for args in mock_triples:
       

       _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
       

       

       self = <vcr.patch.CassettePatcherBuilder object at 0x7fdb0f426eb8>
       

       

       @_build_patchers_from_mock_triples_decorator
       

       def _tornado(self):
       

       try:
       

       import tornado.simple_httpclient as simple
       

       except ImportError:  # pragma: no cover
       

       pass
       

       else:
       

       from .stubs.tornado_stubs import vcr_fetch_impl
       

       

       new_fetch_impl = vcr_fetch_impl(self._cassette, _SimpleAsyncHTTPClient_fetch_impl)
       

       yield simple.SimpleAsyncHTTPClient, "fetch_impl", new_fetch_impl
       

       try:
       

       >           import tornado.curl_httpclient as curl
       

       
        E           AttributeError: module 'tornado' has no attribute 'curl_httpclient'
       
       

       

       new_fetch_impl = <function SimpleAsyncHTTPClient.fetch_impl at 0x7fdb1fd6c7b8>
       

       self       = <vcr.patch.CassettePatcherBuilder object at 0x7fdb0f426eb8>
       

       simple     = <module 'tornado.simple_httpclient' from '/app/platform/venv/lib/python3.5/site-packages/tornado/simple_httpclient.py'>
       

       vcr_fetch_impl = <function vcr_fetch_impl at 0x7fdb15097d08>
       

       

       venv/lib/python3.5/site-packages/vcr/patch.py:295: AttributeError

Tags: pyvenvlibpackagesexceptionsitefetchitem