![ubuntu 升级py3compile未找到问题](https://linux22.com/image/910123/ubuntu%20%E5%8D%87%E7%BA%A7py3compile%E6%9C%AA%E6%89%BE%E5%88%B0%E9%97%AE%E9%A2%98.png)
Ubuntu:18.04
当我尝试 sudo apt-get upgrade
这样做时出现了这个错误:
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
The following packages were automatically installed and are no longer required:
libpython3.7-minimal libpython3.7-stdlib
Use 'sudo apt autoremove' to remove them.
0 to upgrade, 0 to newly install, 0 to remove and 0 not to upgrade.
1 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] y
Setting up python3-software-properties (0.96.24.32.7) ...
/var/lib/dpkg/info/python3-software-properties.postinst: 6: /var/lib/dpkg/info/python3-software-properties.postinst: py3compile: not found
dpkg: error processing package python3-software-properties (--configure):
installed python3-software-properties package post-installation script subprocess returned error exit status 127
Errors were encountered while processing:
python3-software-properties
E: Sub-process /usr/bin/dpkg returned an error code (1)
但建议的推荐sudo apt autoremove
也显示错误:
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be REMOVED
libpython3.7-minimal libpython3.7-stdlib
0 to upgrade, 0 to newly install, 2 to remove and 0 not to upgrade.
1 not fully installed or removed.
After this operation, 12.1 MB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 178285 files and directories currently installed.)
Removing libpython3.7-stdlib:amd64 (3.7.1-1~18.04) ...
Removing libpython3.7-minimal:amd64 (3.7.1-1~18.04) ...
Setting up python3-software-properties (0.96.24.32.7) ...
/var/lib/dpkg/info/python3-software-properties.postinst: 6: /var/lib/dpkg/info/python3-software-properties.postinst: py3compile: not found
dpkg: error processing package python3-software-properties (--configure):
installed python3-software-properties package post-installation script subprocess returned error exit status 127
Errors were encountered while processing:
python3-software-properties
E: Sub-process /usr/bin/dpkg returned an error code (1)
因此,看起来 py3compile 存在一些未发现的问题。我尝试了sudo apt-get -f install
以下方法,结果如下:
Reading package lists... Done
Building dependency tree
Reading state information... Done
0 to upgrade, 0 to newly install, 0 to remove and 0 not to upgrade.
1 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Setting up python3-software-properties (0.96.24.32.7) ...
/var/lib/dpkg/info/python3-software-properties.postinst: 6: /var/lib/dpkg/info/python3-software-properties.postinst: py3compile: not found
dpkg: error processing package python3-software-properties (--configure):
installed python3-software-properties package post-installation script subprocess returned error exit status 127
Errors were encountered while processing:
python3-software-properties
E: Sub-process /usr/bin/dpkg returned an error code (1)
当我尝试时,会出现同样的 py3compile: not found 错误sudo apt-get install --reinstall python3-minimal
我是 ubuntu 新手,因此我很乐意获得一些帮助。
答案1
这个答案对我有帮助,希望它能解决一些人的问题。
通过以下方式重新配置所有已解压但未配置的软件包:
sudo dpkg --configure -a
如果上述方法无效,请尝试python3-minimal
通过以下方式重新安装包:
sudo apt install -f --reinstall python3-minimal
或者,运行:
apt-get download python3-minimal
sudo dpkg -i *python3*.deb
sudo apt install -f
或者从 kernel.org 下载 .deb 文件并通过以下方式从文件安装:
sudo dpkg -i python3-minimal_*.deb
答案2
py3compile not found
我在安装 Ubuntu 20.04.1 时遇到了问题python3-pip
。我python3-minimal
按照答案的建议重新安装,然后再次尝试安装python3-pip
,成功了!
sudo apt install -f --reinstall python3-minimal
sudo apt install -f --reinstall python3-pip
希望这对将来的某人有所帮助!
答案3
就我而言,我正在升级 Ubuntu 16。我的解决方案是将默认的 /usr/bin/python 设置回 python2,因为 python3 没有所需的所有依赖项。
rm /usr/bin/python /usr/bin/python3
ln -sf /usr/bin/python2.7 /usr/bin/python