You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Ubuntu Debian9下安装旧版本pip3(回退至9.0.1)求助

Step-by-Step Fix for Your Pip & Statsmodels Issues

Hey there, let's work through this carefully so you don't run into system issues again. I get how frustrating this can be as a Linux newbie—let's take it one step at a time.

1. Fix the Broken Pip3 First (Safely!)

Since upgrading pip3 to 10.1 broke things on Debian 9, we'll roll back to a version that's compatible with your system and Python 3.5. We'll use Python's built-in tools to avoid messing up system paths:

  • First, uninstall the broken pip version using Python's module system (this is safer than trying to run pip3 directly):
    python3 -m pip uninstall -y pip
    
  • Next, reinstall a stable, compatible pip version. Let's go with pip 9.0.3 (a slightly updated version of your original 9.0.1 that's still compatible with Debian 9):
    python3 -m ensurepip --default-pip
    # If ensurepip doesn't work, use this command instead to install pip 9.0.3 directly:
    # python3 -m pip install pip==9.0.3 --force-reinstall
    
  • Verify pip is working again by checking its version:
    pip3 --version
    
    You should see something like pip 9.0.3 from /usr/lib/python3/dist-packages (python 3.5)—that means it's fixed!

2. Fix the Statsmodels ImportError

The original ImportError: cannot import name '_representation' happened because you were probably trying to install a newer statsmodels version that's incompatible with Python 3.5. Let's install the last statsmodels version that supports Python 3.5:

pip3 install statsmodels==0.10.2

This version is fully compatible with Python 3.5 and won't throw that import error. You can verify it works by running:

import statsmodels
print(statsmodels.__version__)

It should output 0.10.2 without any errors.

3. Prevent Future System Issues: Use a Virtual Environment

As a Linux newbie, using virtual environments is a game-changer—it lets you install packages without modifying your system-wide Python setup. If something breaks, you just delete the environment and start fresh, no system damage:

  • Create a virtual environment (replace my_project_env with any name you want):
    python3 -m venv my_project_env
    
  • Activate the environment (you'll see the environment name in your terminal prompt):
    source my_project_env/bin/activate
    
  • Now you can install packages (like statsmodels) here safely—they won't affect your system's Python:
    pip install statsmodels==0.10.2
    
  • When you're done working, deactivate the environment:
    deactivate
    

内容的提问来源于stack exchange,提问作者Jérémie

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.28 09:19:57