Skip to content Skip to sidebar Skip to footer

Import Of 'urllib3.util' Failing In Python 2.7?

I'm working on a Python script written by someone else. I'm trying to get it to run without any problems on my local development machine. I've installed the modules required by the

Solution 1:

Broken install

If for some reason your install of urllib3 is failing to include the util submodule, you could simply download the archive from the pypi page and copy the util folder from there to your urllib3 instal location.

Outdated urllib3

The error you've posted is saying that within urllib3 the relative import of util is failing.

I checked the urllib3 website, and most likely you have an old version of urllib3.

From the changelog:

1.8.2 (2014-04-17)

Fix urllib3.util not being included in the package.

Try updating the module with

sudo pip install urllib3 --upgrade

(or equivalent on your machine)

Alternative

A second reason it could be failing is if you're trying to run the code from within the module. This is generally seen as dangerous and should be avoided.

Confirm which module you're loading

See where your module is by starting a python interpreter and checking where the urllib3 module is being loaded from;

python -c "import urllib3; print urllib3.__file__"

similarly you can check the version:

python -c "import urllib3; print urllib3.__version__"

Manual checking You could also check to make sure that the util submodule is present in the correct location;

ls /usr/local/lib/python2.7/dist-packages/requests/packages/urllib3/util

Solution 2:

Use pip3 : pip3 install urllib3 --upgrade

Post a Comment for "Import Of 'urllib3.util' Failing In Python 2.7?"