无法安装pipenv且升级pip失败求助(Python2.7+Ubuntu环境)
Hey there! Let’s tackle that frustrating pip upgrade error you’re hitting. The TypeError: unsupported operand type(s) for -=: 'Retry' and 'int' you’re seeing is almost always caused by a version conflict between the old urllib3 library on your system and the pip version you’re trying to install. Since you’re on Python 2.7 (which is end-of-life, but we’ll work with what you’ve got) and using an older pip (8.1.1), here are some reliable fixes:
Solution 1: Use easy_install to Upgrade Pip
Since pip itself is having issues, let’s use Python 2.7’s built-in alternative package manager, easy_install, to bypass the problem:
sudo easy_install --upgrade pip==10.0.1
This should directly install the required pip version without triggering the urllib3 conflict.
Solution 2: Manually Install Pip via Wheel
If easy_install doesn’t work, try downloading the pip wheel file directly and installing it:
- Go to the Python Package Index page for pip 10.0.1, download the
pip-10.0.1-py2.py3-none-any.whlfile to your Ubuntu system. - Install it using your current pip (or Python’s wheel module if pip is broken):
pip install pip-10.0.1-py2.py3-none-any.whl # If pip is unresponsive, try this instead: python -m wheel install pip-10.0.1-py2.py3-none-any.whl
(Note: If you don’t have the wheel module installed, run sudo easy_install wheel first.)
Solution 3: Update Pip via Ubuntu’s APT Package Manager
Since you’re on Ubuntu, you can try upgrading pip through the system’s package manager first, which might resolve dependency conflicts automatically:
sudo apt-get update && sudo apt-get install --upgrade python-pip
After this, you can then upgrade pip to the exact 10.0.1 version using:
pip install --upgrade pip==10.0.1
Important Note for Pipenv Installation
Once you have pip 10.0.1 working, keep in mind that newer versions of Pipenv no longer support Python 2.7. To install a compatible version, run:
pip install pipenv==2018.11.26
This is the last Pipenv release that works with Python 2.7.
内容的提问来源于stack exchange,提问作者charbel el hachem

