无法在 Ubuntu 20.04 WSL 中安装 GCC
我尝试在 WSL 上的 Ubuntu 20.04 中安装 gcc :
apt -y install gcc
返回错误:
Reading package lists... Done
Building dependency tree
Reading state information... Done
gcc is already the newest version (4:9.3.0-1ubuntu2).
0 upgraded, 0 newly installed, 0 to remove and 194 not upgraded.
1 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Setting up gcc (4:9.3.0-1ubuntu2) ...
update-alternatives: error: alternative path /usr/bin/gcc doesn't exist
dpkg: error processing package gcc (--configure):
installed gcc package post-installation script subprocess returned error exit status 2
Errors were encountered while processing:
gcc
E: Sub-process /usr/bin/dpkg returned an error code (1)
我尝试使用以下命令修复它:
sudo dpkg --purge --force-depends gcc
sudo apt-get autoremove -y
sudo apt-get autoclean -y
sudo apt-get clean gcc
sudo apt-get install gcc
但随后出现错误:
root@LAP123:/home/my_user# sudo apt-get install gcc
.......
Setting up desktop-file-utils (0.24-1ubuntu3) ...
/var/lib/dpkg/info/desktop-file-utils.postinst: 5: update-desktop-database: not found
dpkg: error processing package desktop-file-utils (--configure):
installed desktop-file-utils package post-installation script subprocess returned error exit status 127
Setting up gcc (4:9.3.0-1ubuntu2) ...
update-alternatives: error: alternative path /usr/bin/gcc doesn't exist
dpkg: error processing package gcc (--configure):
installed gcc package post-installation script subprocess returned error exit status 2
Processing triggers for man-db (2.9.1-1) ...
Errors were encountered while processing:
desktop-file-utils
gcc
E: Sub-process /usr/bin/dpkg returned an error code (1)
如何在 Ubuntu 中安装 gcc?
I have tried to install gcc in Ubuntu 20.04 on WSL :
apt -y install gcc
return error:
Reading package lists... Done
Building dependency tree
Reading state information... Done
gcc is already the newest version (4:9.3.0-1ubuntu2).
0 upgraded, 0 newly installed, 0 to remove and 194 not upgraded.
1 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Setting up gcc (4:9.3.0-1ubuntu2) ...
update-alternatives: error: alternative path /usr/bin/gcc doesn't exist
dpkg: error processing package gcc (--configure):
installed gcc package post-installation script subprocess returned error exit status 2
Errors were encountered while processing:
gcc
E: Sub-process /usr/bin/dpkg returned an error code (1)
I tried to fix it with :
sudo dpkg --purge --force-depends gcc
sudo apt-get autoremove -y
sudo apt-get autoclean -y
sudo apt-get clean gcc
sudo apt-get install gcc
But then I got error :
root@LAP123:/home/my_user# sudo apt-get install gcc
.......
Setting up desktop-file-utils (0.24-1ubuntu3) ...
/var/lib/dpkg/info/desktop-file-utils.postinst: 5: update-desktop-database: not found
dpkg: error processing package desktop-file-utils (--configure):
installed desktop-file-utils package post-installation script subprocess returned error exit status 127
Setting up gcc (4:9.3.0-1ubuntu2) ...
update-alternatives: error: alternative path /usr/bin/gcc doesn't exist
dpkg: error processing package gcc (--configure):
installed gcc package post-installation script subprocess returned error exit status 2
Processing triggers for man-db (2.9.1-1) ...
Errors were encountered while processing:
desktop-file-utils
gcc
E: Sub-process /usr/bin/dpkg returned an error code (1)
How can I install gcc in my Ubuntu?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我可以使用 sudo apt install gcc 安装 GCC,
如果这不起作用,请尝试升级您的软件包。
我在 https://www.systranbox 找到了 YouTube 视频.com/how-to-install-gcc-on-wsl-linux/ 在这方面有些帮助。
I was able to install GCC with sudo apt install gcc
if that doesn't work try upgrading your packages.
I found the YouTube video at https://www.systranbox.com/how-to-install-gcc-on-wsl-linux/ somewhat helpful in that regard.