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

Ubuntu 20.04重装Python3后出现ModuleNotFoundError问题求助

Ubuntu 20.04重装Python3后出现ModuleNotFoundError问题求助

Hey Bilal, sorry to hear you're stuck with this frustrating error after reinstalling Python 3 on Ubuntu 20.04. Let's walk through some targeted fixes that should resolve the ModuleNotFoundError for softwareproperties.SoftwareProperties:

  • Check your system's default Python 3 symlink
    Ubuntu 20.04 relies on Python 3.8 as its default system Python, and mismatched symlinks are a common culprit here. First, verify where python3 points:
    ls -l /usr/bin/python3
    If it doesn't link to /usr/bin/python3.8, fix it with these commands:
    sudo rm /usr/bin/python3
    sudo ln -s /usr/bin/python3.8 /usr/bin/python3

  • Fully reinstall software-properties-common
    A simple reinstall might not clear corrupted files—try purging the package completely first:
    sudo apt purge --auto-remove software-properties-common
    sudo apt update
    sudo apt install software-properties-common

  • Verify Python can access the softwareproperties module
    The module lives in /usr/lib/python3/dist-packages, so check if this path is in Python's system path. Run python3 in your terminal and enter:
    import sys; print(sys.path)
    If /usr/lib/python3/dist-packages isn't listed, ensure the directory has correct permissions:
    sudo chmod -R 755 /usr/lib/python3/dist-packages
    You can also try re-registering the module via pip (though it's typically managed by apt):
    sudo python3 -m pip install --upgrade pip
    sudo python3 -m pip install software-properties-common

  • Fix the add-apt-repository script's shebang line
    Sometimes the script points to the wrong Python version. Open it with a text editor:
    sudo nano /usr/bin/add-apt-repository
    Check the first line—it should be either #!/usr/bin/python3 or #!/usr/bin/python3.8. If it's incorrect, modify it, save with Ctrl+O, then exit with Ctrl+X.

  • Reinstall core system Python packages
    If none of the above works, restore the minimal system Python components:
    sudo apt install --reinstall python3-minimal python3.8-minimal

Give these steps a try one by one—most users fix this issue with the first two steps. Let me know if you run into any snags!

备注:内容来源于stack exchange,提问作者Bilal

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.04.23 12:47:44