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

