Ubuntu16.04下pip3安装Kmodes报AttributeError问题求助
Hey there, I’ve dealt with this exact frustrating error on Ubuntu 16.04 before—let’s get you past it. The root issue here is that Ubuntu 16.04’s default pip3 and setuptools versions are outdated and often clash when you try to upgrade them directly. Here’s the step-by-step fix that worked for me:
Step 1: Fully purge system-installed pip3 and setuptools
First, we need to wipe out the old, conflicting packages from your system completely:
- Uninstall the system
python3-pippackage along with its dependencies:sudo apt-get purge --auto-remove python3-pip - Delete any leftover pip/setuptools files in your Python 3.5 directory (Ubuntu 16.04 uses Python 3.5 by default):
sudo rm -rf /usr/local/lib/python3.5/dist-packages/pip* sudo rm -rf /usr/local/lib/python3.5/dist-packages/setuptools*
Step 2: Reinstall pip3 using the official version-specific bootstrap script
The system’s apt repo has way-too-old versions, so we’ll use the official pip script tailored for Python 3.5 (newer pip versions don’t support Python 3.5 anymore):
- Download the compatible bootstrap script:
curl https://bootstrap.pypa.io/pip/3.5/get-pip.py -o get-pip.py - Run the script to install a working, compatible version of pip3 and setuptools:
sudo python3 get-pip.py
Step 3: Verify your installation
Double-check that you now have compatible versions installed:
- Check pip3 version (should be around 20.3.x, the last version supporting Python 3.5):
pip3 --version - Check setuptools version to confirm it’s paired correctly with pip:
pip3 show setuptools
Step 4: Install Kmodes without errors
Now you should be able to install Kmodes smoothly:
pip3 install kmodes
Why your previous attempts didn’t work
Ubuntu 16.04’s default pip3 is so outdated that running pip3 install --upgrade pip setuptools often leaves behind conflicting files or fails to fully upgrade due to system permission constraints. Purging everything first ensures you start with a clean slate, and using the version-specific bootstrap script guarantees compatibility with your Python 3.5 installation.
内容的提问来源于stack exchange,提问作者DeeS

