OS: Mac OS X. When I\'m trying to run the code below, I get the error:
ImportError: cannot import name HeaderParsingError
I\'ve
It could be an issue with the "urllib3" package itself. uninstall/install will fix the problem.
sudo pip uninstall urllib3
sudo pip install --upgrade urllib3
In my case, the error was:
ImportError: cannot import name UnrewindableBodyError
Another issue could be that, urllib3 was installed via pip, and requests installed via yum repo, or vice-versa. In that case, the fix is to completely remove these libraries and install it via same repo.
I recommend pip over yum to install both packages as it is easy to maintain and gives more control. Any further yum updates required for OS patching or VM maintenance activities etc., won't impact the packages installed via pip.
First remove all installations of “urllib3” and “requests” via pip and yum:
sudo pip uninstall urllib3 -y
sudo pip uninstall requests -y
sudo yum remove python-urllib3 -y
sudo yum remove python-requests -y
To have single source of installations, use either of the below steps, not both.
Now install both packages only via pip:
sudo pip install --upgrade urllib3
sudo pip install --upgrade requests
Or, use only yum. I prefer pip over yum as explained above.
To install both packages only via yum:
sudo yum install python-urllib3
sudo yum install python-requests
Note: Always use virtual environment to avoid conflicts when an yum update happens at OS level.