when running test i'm getting this error.
我之前使用python-requests v2.2.1
。所以,
我已将python-requests
升级为v2.14.2
,但我仍面临同样的问题
HeaderDict(requests.packages.urllib3._collections.HTTPHeaderDict):
AttributeError: 'module' object has no attribute 'packages'
检查以下结果:
======================================================================
ERROR: rest_blog.tests.test_views (unittest.loader.ModuleImportFailure)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/lib/python3.4/unittest/case.py", line 58, in testPartExecutor
yield
File "/usr/lib/python3.4/unittest/case.py", line 577, in run
testMethod()
File "/usr/lib/python3.4/unittest/loader.py", line 32, in testFailure
raise exception
ImportError: Failed to import test module: rest_blog.tests.test_views
Traceback (most recent call last):
File "/usr/lib/python3.4/unittest/loader.py", line 312, in _find_tests
module = self._get_module_from_name(name)
File "/usr/lib/python3.4/unittest/loader.py", line 290, in _get_module_from_name
__import__(name)
File "/home/vamsi/PycharmProjects/ReminderToDo/rest_blog/tests/test_views.py", line 6, in <module>
from rest_framework.test import force_authenticate
File "/usr/local/lib/python3.4/dist-packages/rest_framework/test.py", line 30, in <module>
class HeaderDict(requests.packages.urllib3._collections.HTTPHeaderDict):
AttributeError: 'module' object has no attribute 'packages'
----------------------------------------------------------------------
&#13;
答案 0 :(得分:3)
只需重新安装请求或升级请求即可解决问题。
pip install --upgrade requests