Pip does not work on linux returning error:"from urllib3.packages.ordered_dict import OrderedDict ImportError: No module named ordered_dict"

1

I noticed i couldn't use pip anymore because of Import error whatever i do with pip, can't eve just run "pip" without getting:

Traceback (most recent call last):
File "/usr/bin/pip", line 9, in <module>
load_entry_point('pip==1.5.6', 'console_scripts', 'pip')()
File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 489, 
in load_entry_point
File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 2843, 
in load_entry_point
File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 2434, 
in load
File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 2440, 
in resolve
File "/usr/lib/python2.7/dist-packages/pip/__init__.py", line 74, in 
<module>
from pip.vcs import git, mercurial, subversion, bazaar  # noqa
File "/usr/lib/python2.7/dist-packages/pip/vcs/mercurial.py", line 9, in 
<module>
from pip.download import path_to_url
File "/usr/lib/python2.7/dist-packages/pip/download.py", line 22, in 
<module>
import requests, six
File "/usr/lib/python2.7/dist-packages/requests/__init__.py", line 80, in 
<module>
from . import utils
File "/usr/lib/python2.7/dist-packages/requests/utils.py", line 25, in 
<module>
from .compat import parse_http_list as _parse_list_header
File "/usr/lib/python2.7/dist-packages/requests/compat.py", line 94, in 
<module>
from urllib3.packages.ordered_dict import OrderedDict
ImportError: No module named ordered_dict

canno install urllib3 or setuputils using pip so i tryed downloading and then setup.py install them. Nothing worked. What could i do?

Giuseppe

Posted 2019-05-15T15:57:05.957

Reputation: 11

Answers

0

I had this exact issue, and the common solution for this issue is to downgrade the urllib3 with pip. However, as you are aware, we can't execute any pip command due to the above error, so downgrading is not a solution for this problem.

The answer is that you most probably has wrong urllib3 version installed.

I have two different versions installed in my pc and pip took the wrong version (with no OrderedDict). To check, run your python intepreter and check your urllib3 version.

import urllib3
urllib3.__version__
'1.16'

Ensure that you don't have a prior older urllib3 installed (for my case, i had it installed by apt-get install python-urllib3, and later also installed by python-pip)

After removing python-urllib3, check the you don't have urllib3 installed anymore under

cd /usr/local/lib/python2.7/dist-packages/

if it has no urllib3, reinstall python-pip (that will also install urllib3 with the correct version).

sateayam

Posted 2019-05-15T15:57:05.957

Reputation: 101