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

Ubuntu 20.04安装python3-venv失败,存在损坏软件包问题求助

问题:Ubuntu 20.04安装python3-venv依赖冲突无法创建虚拟环境

按照Ubuntu 20.04的Python编程环境搭建教程操作时,安装python3-venv遇到一系列依赖问题,具体过程如下:

  • 执行以下命令安装基础依赖:

    sudo apt install build-essential libssl-dev libffi-dev python3-dev
    

    报错:

    libffi-dev python3-dev
    Reading package lists... Done
    Building dependency tree
    Reading state information... Done
    libffi-dev is already the newest version (3.3-4).
    build-essential is already the newest version (12.8ubuntu1.1).
    libssl-dev is already the newest version (1.1.1f-1ubuntu2.16).
    Some packages could not be installed. This may mean that you have
    requested an impossible situation or if you are using the unstable
    distribution that some required packages have not yet been created
    or been moved out of Incoming.
    The following information may help to resolve the situation:

    The following packages have unmet dependencies:
    python3-dev : Depends: libpython3-dev (= 3.8.2-0ubuntu2) but it is not going to be installed
    Depends: python3.8-dev (>= 3.8.2-1~) but it is not going to be installed
    E: Unable to correct problems, you have held broken packages.

    去掉python3-dev后单独安装python3,命令执行成功。

  • 执行命令安装python3-venv:

    sudo apt install -y python3-venv
    

    报错:

    Reading package lists... Done
    Building dependency tree
    Reading state information... Done
    Some packages could not be installed. This may mean that you have
    requested an impossible situation or if you are using the unstable
    distribution that some required packages have not yet been created
    or been moved out of Incoming.
    The following information may help to resolve the situation:

    The following packages have unmet dependencies:
    python3-venv : Depends: python3.8-venv (>= 3.8.2-1~) but it is not going to be installed
    E: Unable to correct problems, you have held broken packages.

  • 尝试单独安装python3.8-venv:

    sudo apt install -y python3.8-venv
    

    报错:

    Reading package lists... Done
    Building dependency tree
    Reading state information... Done
    Some packages could not be installed. This may mean that you have
    requested an impossible situation or if you are using the unstable
    distribution that some required packages have not yet been created
    or been moved out of Incoming.
    The following information may help to resolve the situation:

    The following packages have unmet dependencies:
    python3.8-venv : Depends: python3.8 (= 3.8.10-0ubuntu1~20.04.5) but 3.8.13-1+bionic2 is to be installed
    E: Unable to correct problems, you have held broken packages.

  • 检查python3.8版本:

    sudo apt install -y python3.8
    

    输出显示已安装最新版本:

    Reading package lists... Done
    Building dependency tree
    Reading state information... Done
    python3.8 is already the newest version (3.8.13-1+bionic2).
    0 upgraded, 0 newly installed, 0 to remove and 6 not upgraded.

  • 尝试直接创建虚拟环境:

    python3 -m venv myEnv
    

    报错:

    Error: Command '['/home/yash/Desktop/DashMed/myEnv/bin/python3', '-Im', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 1.

目前陷入死循环,无法正常创建虚拟环境,寻求解决方法。


内容的提问来源于stack exchange,提问作者Yash J

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.15 15:45:42