我是 Linux 新手,我正在尝试安装 node、npm、yarn,然后安装 vuejs/vitejs……我能够成功安装 node、npm 和 yarn,但是当我尝试使用 npm 安装时,它说我有一个旧版本的 node。
自从我安装了这些软件包后,每当我尝试安装、删除或升级任何新软件包时,我都会收到以下错误。
Reading package lists... Done
Building dependency tree
Reading state information... Done
0 upgraded, 0 newly installed, 1 reinstalled, 0 to remove and 7 not upgraded.
4 not fully installed or removed.
Need to get 1,136 kB of archives.
After this operation, 0 B of additional disk space will be used.
Get:1 http://ci.archive.ubuntu.com/ubuntu bionic-updates/main amd64 dpkg amd64 1.19.0.5ubuntu2.3 [1,136 kB]
Fetched 1,136 kB in 2s (535 kB/s)
(Reading database ... 338279 files and directories currently installed.)
Preparing to unpack .../dpkg_1.19.0.5ubuntu2.3_amd64.deb ...
Unpacking dpkg (1.19.0.5ubuntu2.3) over (1.19.0.5ubuntu2.3) ...
Setting up dpkg (1.19.0.5ubuntu2.3) ...
Setting up python3-xapian (1.4.5-1ubuntu3) ...
/var/lib/dpkg/info/python3-xapian.postinst: 6: /var/lib/dpkg/info/python3-xapian.postinst: py3compile: not found
dpkg: error processing package python3-xapian (--configure):
installed python3-xapian package post-installation script subprocess returned error exit status 127
Setting up python3-problem-report (2.20.9-0ubuntu7.24) ...
/var/lib/dpkg/info/python3-problem-report.postinst: 6: /var/lib/dpkg/info/python3-problem-report.postinst: py3compile: not found
dpkg: error processing package python3-problem-report (--configure):
installed python3-problem-report package post-installation script subprocess returned error exit status 127
Setting up python3-configobj (5.0.6-2) ...
/var/lib/dpkg/info/python3-configobj.postinst: 6: /var/lib/dpkg/info/python3-configobj.postinst: py3compile: not found
dpkg: error processing package python3-configobj (--configure):
installed python3-configobj package post-installation script subprocess returned error exit status 127
Setting up python3-dateutil (2.6.1-1) ...
/var/lib/dpkg/info/python3-dateutil.postinst: 6: /var/lib/dpkg/info/python3-dateutil.postinst: py3compile: not found
dpkg: error processing package python3-dateutil (--configure):
installed python3-dateutil package post-installation script subprocess returned error exit status 127
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
Processing triggers for libc-bin (2.27-3ubuntu1.4) ...
Errors were encountered while processing:
python3-xapian
python3-problem-report
python3-configobj
python3-dateutil
我安装了 python3.9 并将其符号链接到 python3。在我尝试专门安装 yarn 之前,一切仍然运行良好。
我也尝试再次使用 npm,但遇到了同样的错误。
Python3也出现这个错误:
bash: python3: command not found
答案1
不要将 Python3 链接到不同版本的 Python。
python3
必须链接到系统提供的 Python 版本,以便您的系统正常工作。例如,apt 依赖于该特定版本;当您更改链接时,apt 就被破坏了。
要使用不同版本的 Python,请将其保存在容器或 venv 中。您可以在容器/venv 中链接任何您喜欢的内容。
恢复更改。您曾经更改过链接;只需将其改回来即可。