我正在尝试运行该命令sudo apt-get install build-essential libssl-dev -y
。但对于大多数apt-get update
命令,我最终都会收到以下错误。不确定这里的 python 包有什么问题
E: py3compile:243: Requested versions are not installed
dpkg: error processing package python3-apt (--configure):
subprocess installed post-installation script returned error exit status 3
Errors were encountered while processing:
python3-minimal
python3-apt
E: Sub-process /usr/bin/dpkg returned an error code (1)
系统信息:
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 16.04.2 LTS
Release: 16.04
Codename: xenial
Python 版本:
$ python --version
Python 2.7.12
$ python3 --version
Python 3.7.4
$ apt-cache policy python3-minimal
python3-minimal:
Installed: 3.5.1-3
Candidate: 3.5.1-3
Version table:
*** 3.5.1-3 500
500 http://archive.ubuntu.com/ubuntu xenial/main amd64 Packages
100 /var/lib/dpkg/status
& type -a python3
python3 is /home/linuxbrew/.linuxbrew/bin/python3
python3 is /home/linuxbrew/.linuxbrew/bin/python3
python3 is /home/linuxbrew/.linuxbrew/bin/python3
python3 is /home/linuxbrew/.linuxbrew/bin/python3
python3 is /usr/bin/python3
$ file /usr/bin/python3
/usr/bin/python3: symbolic link to /usr/bin/python3.7
$ echo $PATH
/bin:/usr/local/go/bin:/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin:/home/rxy/bin:/home/rxy/.local/bin:/bin:/usr/local/go/bin:/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin:/home/rxy/bin:/home/rxy/.local/bin:/bin:/usr/local/go/bin:/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin:/home/rxy/bin:/home/rxy/.local/bin:/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin:/home/rxy/bin:/home/rxy/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/usr/lib/jvm/java-8-oracle/bin:/usr/lib/jvm/java-8-oracle/db/bin:/usr/lib/jvm/java-8-oracle/jre/bin:/usr/local/go/bin:/usr/local/go/bin:/usr/local/go/bin:/usr/local/go/bin
file /usr/bin/python3.5
/usr/bin/python3.5: cannot open `/usr/bin/python3.5' (No such file or directory)
内容~/.profile
:
# ~/.profile: executed by the command interpreter for login shells.
# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login
# exists.
# see /usr/share/doc/bash/examples/startup-files for examples.
# the files are located in the bash-doc package.
# the default umask is set in /etc/profile; for setting the umask
# for ssh logins, install and configure the libpam-umask package.
#umask 022
# if running bash
if [ -n "$BASH_VERSION" ]; then
# include .bashrc if it exists
if [ -f "$HOME/.bashrc" ]; then
. "$HOME/.bashrc"
fi
fi
# set PATH so it includes user's private bin directories
PATH="$HOME/bin:$HOME/.local/bin:$PATH"
export PATH='/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin':"$PATH"
export PATH=$PATH:/usr/local/go/bin
答案1
我思考了很长时间,最后想出了这个解决方案(虽然不是很好,但如果可行的话):
基于这样的想法,Python 本质上是一种解释型语言,py3compile
可能很好但不是需要的,所以:
mv /usr/bin/py3compile /usr/bin/py3compile.orig
ln -s $(which true) /usr/bin/py3compile
答案2
py3compile 文件由 python3-minimal 提供,其在 Xenial Xerus 上的默认版本是 3.5.1-3,根据Ubuntu 软件包搜索,这取决于python3.5-minimal
,但您安装了 python3.7-minimal,并将默认 python3 设置为 python3.7,这是一个非常糟糕的主意。Python 是 Linux 系统不可或缺的一部分,除非您正在进行实验并且有破坏系统的情绪,否则不应触碰默认 Python。
您需要通过安装python3.5 minimal
软件包和更改符号链接来恢复默认的 Python 3(对您而言是 3.5)。为此,请运行:
sudo apt install python3.5-minimal
sudo ln -sf /usr/bin/python3.5 /usr/bin/python3
此外,变量中路径的顺序也定义了优先级。您可以考虑通过修改和更改PATH
将自定义路径移到最后~/.profile
export PATH='/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin':"$PATH"
到
export PATH="$PATH":'/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin'
注销并重新登录以使更改生效。运行
sudo dpkg --configure -a
并重试安装问题中提到的软件包。