如何在 ubuntu 18.04 上安装 python-dev(适用于 python 2.7)?

如何在 ubuntu 18.04 上安装 python-dev(适用于 python 2.7)?

Ubuntu 18.04。我有一个 pip (2.7) 安装,由于找不到“Python.h”而失败。我尝试了这个:

$ sudo apt install python-dev --fix-missing

并得到以下输出:

Reading package lists... Done
Building dependency tree... 50%
Building dependency tree       
Reading state information... Done
The following package was automatically installed and is no longer required:
  python-all
Use 'sudo apt autoremove' to remove it.
The following additional packages will be installed:
  libpython-dev libpython2.7 libpython2.7-dev python2.7-dev
The following NEW packages will be installed:
  libpython-dev libpython2.7 libpython2.7-dev python-dev python2.7-dev
0 upgraded, 5 newly installed, 0 to remove and 1 not upgraded.
Need to get 29.6 MB/29.6 MB of archives.
After this operation, 45.5 MB of additional disk space will be used.
Ign:1 http://us.archive.ubuntu.com/ubuntu bionic-updates/main amd64 libpython2.7 amd64 2.7.15-4ubuntu4~18.04.1
Ign:2 http://us.archive.ubuntu.com/ubuntu bionic-updates/main amd64 libpython2.7-dev amd64 2.7.15-4ubuntu4~18.04.1
Ign:3 http://us.archive.ubuntu.com/ubuntu bionic-updates/main amd64 python2.7-dev amd64 2.7.15-4ubuntu4~18.04.1
Err:1 http://us.archive.ubuntu.com/ubuntu bionic-updates/main amd64 libpython2.7 amd64 2.7.15-4ubuntu4~18.04.1
  404  Not Found [IP: 91.189.91.14 80]
Err:2 http://us.archive.ubuntu.com/ubuntu bionic-updates/main amd64 libpython2.7-dev amd64 2.7.15-4ubuntu4~18.04.1
  404  Not Found [IP: 91.189.91.14 80]
Err:3 http://us.archive.ubuntu.com/ubuntu bionic-updates/main amd64 python2.7-dev amd64 2.7.15-4ubuntu4~18.04.1
  404  Not Found [IP: 91.189.91.14 80]
Unable to correct missing packages.
E: Failed to fetch http://us.archive.ubuntu.com/ubuntu/pool/main/p/python2.7/libpython2.7_2.7.15-4ubuntu4~18.04.1_amd64.deb  404  Not Found [IP: 91.189.91.14 80]
E: Failed to fetch http://us.archive.ubuntu.com/ubuntu/pool/main/p/python2.7/libpython2.7-dev_2.7.15-4ubuntu4~18.04.1_amd64.deb  404  Not Found [IP: 91.189.91.14 80]
E: Failed to fetch http://us.archive.ubuntu.com/ubuntu/pool/main/p/python2.7/python2.7-dev_2.7.15-4ubuntu4~18.04.1_amd64.deb  404  Not Found [IP: 91.189.91.14 80]
E: Aborting install.

我需要做什么才能安装 python-dev?

答案1

sudo sed -i s,//us.archive,//archive,g  /etc/apt/sources.list

或使用

software-properties-gtk 

在此处输入图片描述

并选择从主服务器下载。

在那之后

sudo apt update && sudo apt install python-dev

两种方法都会将 apt 源更改为主服务器。

相关内容