Python requests ImportError: cannot import name HeaderParsingError

前端 未结 3 1217
梦谈多话
梦谈多话 2021-01-05 08:16

OS: Mac OS X. When I\'m trying to run the code below, I get the error:

ImportError: cannot import name HeaderParsingError

I\'ve

3条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-05 08:23

    requests comes with its own copy of the urllib3 library, in the requests/packages subdirectory. It is this copy that is somehow broken.

    Reinstall requests itself; either upgrade (you have at most version 2.1.0, given the from .packages import charade as chardet line), or reinstall the existing version.

    Reinstalling with pip can be done with the --force-reinstall switch:

    pip install --force-reinstall requests==2.1.0
    

    or force an upgrade:

    pip install --upgrade requests
    

提交回复
热议问题