Software⏱️ 3 min read📅 2026-06-15

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

pip error on linux due to ordered_dict import issue

Quick Answer: Try installing urllib3 and setuptools using a package manager like apt or yum, then try reinstalling pip.

The error 'ImportError: No module named ordered_dict' in pip is affecting Linux users, preventing them from using pip to install packages. This issue can be frustrating for developers and system administrators who rely on pip for package management.

This error occurs when the pip installation tries to use the urllib3 package, which requires the ordered_dict module. However, the ordered_dict module is not installed or cannot be found by pip, resulting in this error.

🛑 Root Causes of the Error

  • The primary cause of this error is that the pip installation is trying to use a version of urllib3 that requires the ordered_dict module, which is not installed or available. This can happen if the system has an outdated version of pip or if the dependencies are not properly configured.
  • Another possible cause is that the system's Python environment is using a different version of pip than the one that was used to install the required packages.

🔧 Proven Troubleshooting Steps

Updating pip and installing urllib3

  1. Step 1: Update pip to the latest version using the following command: `sudo apt update && sudo apt install python3-pip` (for Ubuntu-based systems) or `sudo yum update && sudo yum install python-pip` (for RHEL-based systems).
  2. Step 2: Install urllib3 using pip: `pip3 install --upgrade urllib3`.
  3. Step 3: Check if the ordered_dict module is installed by running `python -c 'import urllib3; print(urllib3.packages.ordered_dict)'`. If it's not installed, proceed to the next step.

Installing pip and setuptools from source

  1. Step 1: Download the pip installer using `wget https://bootstrap.pypa.io/get-pip.py`.
  2. Step 2: Run the installer: `python get-pip.py`. This may take a few minutes to complete.
  3. Step 3: Install urllib3 using pip: `pip install urllib3`.

✨ Wrapping Up

To resolve the 'ImportError: No module named ordered_dict' issue in pip, update pip and install urllib3 using the steps outlined above. If updating pip is not possible, consider installing pip and setuptools from source to ensure that all dependencies are properly installed.

Did this fix your problem?

If not, try searching for specific error codes.

🔍 Search Error Database

❓ Frequently Asked Questions