Ubuntu sudo apt-get update提示 Failed to fetch,解决办法

问题:

执行sudo apt-get update提示:Failed to fetch

chen@ubuntu:~/soft/Python-2.7.12$ sudo apt-get update
Get:1 http://ppa.launchpad.net/fkrull/deadsnakes-python2.7/ubuntu xenial InRelease [2,281 B]
Err:1 http://ppa.launchpad.net/fkrull/deadsnakes-python2.7/ubuntu xenial InRelease
  Clearsigned file isn't valid, got 'NOSPLIT' (does the network require authentication?)
Fetched 2,281 B in 0s (4,524 B/s)    
Reading package lists... Done
E: Failed to fetch http://ppa.launchpad.net/fkrull/deadsnakes-python2.7/ubuntu/dists/xenial/InRelease  Clearsigned file isn't valid, got 'NOSPLIT' (does the network require authentication?)
E: Some index files failed to download. They have been ignored, or old ones used instead.

但是在虚拟机里面直接访问:http://ppa.launchpad.net/fkrull/deadsnakes-python2.7/ubuntu 是可以的啊

一、删除文件

  sudo rm -rf /var/lib/apt/lists

二、删除所有源

  

  

三、修改源

sudo vi /etc/apt/sources.list

里面写入163的源

deb http://mirrors.163.com/ubuntu/ xenial main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ xenial-security main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ xenial-updates main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ xenial-proposed main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ xenial-backports main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ xenial main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ xenial-security main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ xenial-updates main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ xenial-proposed main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ xenial-backports main restricted universe multiverse

  查看源

  

四、测试

再次sudo apt-get update

  提示如下:

guchen@ubuntu:~/soft/Python-2.7.12$ sudo apt-get update
Get:1 http://mirrors.163.com/ubuntu xenial InRelease [2,281 B]
Get:2 http://mirrors.163.com/ubuntu xenial-security InRelease [2,281 B]
Err:1 http://mirrors.163.com/ubuntu xenial InRelease                                
  Clearsigned file isn't valid, got 'NOSPLIT' (does the network require authentication?)
Err:2 http://mirrors.163.com/ubuntu xenial-security InRelease                       
  Clearsigned file isn't valid, got 'NOSPLIT' (does the network require authentication?)
Get:3 http://mirrors.163.com/ubuntu xenial-updates InRelease [2,281 B]              
Err:3 http://mirrors.163.com/ubuntu xenial-updates InRelease                  
  Clearsigned file isn't valid, got 'NOSPLIT' (does the network require authentication?)
Get:4 http://mirrors.163.com/ubuntu xenial-proposed InRelease [2,281 B]       
Err:4 http://mirrors.163.com/ubuntu xenial-proposed InRelease                       
  Clearsigned file isn't valid, got 'NOSPLIT' (does the network require authentication?)
Get:5 http://mirrors.163.com/ubuntu xenial-backports InRelease [2,281 B]            
Err:5 http://mirrors.163.com/ubuntu xenial-backports InRelease
  Clearsigned file isn't valid, got 'NOSPLIT' (does the network require authentication?)
Fetched 9,124 B in 0s (19.8 kB/s)
Reading package lists... Done
E: Failed to fetch http://mirrors.163.com/ubuntu/dists/xenial/InRelease  Clearsigned file isn't valid, got 'NOSPLIT' (does the network require authentication?)
E: Failed to fetch http://mirrors.163.com/ubuntu/dists/xenial-security/InRelease  Clearsigned file isn't valid, got 'NOSPLIT' (does the network require authentication?)
E: Failed to fetch http://mirrors.163.com/ubuntu/dists/xenial-updates/InRelease  Clearsigned file isn't valid, got 'NOSPLIT' (does the network require authentication?)
E: Failed to fetch http://mirrors.163.com/ubuntu/dists/xenial-proposed/InRelease  Clearsigned file isn't valid, got 'NOSPLIT' (does the network require authentication?)
E: Failed to fetch http://mirrors.163.com/ubuntu/dists/xenial-backports/InRelease  Clearsigned file isn't valid, got 'NOSPLIT' (does the network require authentication?)
E: Some index files failed to download. They have been ignored, or old ones used instead.

五、切换认证

怎么还提示:does the network require authentication?

需要权限??

解决方法:将software$updates中的Authentication换一个试试

六、成功

  最后再执行一下:

sudo apt-get clean

sudo apt-get update

guchen@ubuntu:~/soft/Python-2.7.12$ sudo apt-get update
Get:1 http://mirrors.163.com/ubuntu xenial InRelease [247 kB]
Get:2 http://mirrors.163.com/ubuntu xenial-security InRelease [107 kB]
Get:3 http://mirrors.163.com/ubuntu xenial-updates InRelease [109 kB]
Get:4 http://mirrors.163.com/ubuntu xenial-proposed InRelease [260 kB]
Get:5 http://mirrors.163.com/ubuntu xenial-backports InRelease [107 kB]
Get:6 http://mirrors.163.com/ubuntu xenial/main Sources [868 kB]
Get:7 http://mirrors.163.com/ubuntu xenial/restricted Sources [4,808 B]
Get:8 http://mirrors.163.com/ubuntu xenial/universe Sources [7,728 kB]
Get:9 http://mirrors.163.com/ubuntu xenial/multiverse Sources [179 kB]            
Get:10 http://mirrors.163.com/ubuntu xenial/main amd64 Packages [1,201 kB]
Get:11 http://mirrors.163.com/ubuntu xenial/main i386 Packages [1,196 kB]
Get:12 http://mirrors.163.com/ubuntu xenial/main Translation-en [568 kB]
Get:13 http://mirrors.163.com/ubuntu xenial/main amd64 DEP-11 Metadata [733 kB]
Get:14 http://mirrors.163.com/ubuntu xenial/main DEP-11 64x64 Icons [409 kB]
Get:15 http://mirrors.163.com/ubuntu xenial/restricted amd64 Packages [8,344 B]
Get:16 http://mirrors.163.com/ubuntu xenial/restricted i386 Packages [8,684 B]
Get:17 http://mirrors.163.com/ubuntu xenial/restricted Translation-en [2,908 B]
Get:18 http://mirrors.163.com/ubuntu xenial/restricted amd64 DEP-11 Metadata [186 B]
Get:19 http://mirrors.163.com/ubuntu xenial/universe amd64 Packages [7,532 kB]
Get:102 http://mirrors.163.com/ubuntu xenial-backports/universe DEP-11 64x64 Icons [1,789 B]                                                                                                                                                    
Get:103 http://mirrors.163.com/ubuntu xenial-backports/multiverse amd64 DEP-11 Metadata [216 B]                                                                                                                                                 
Get:104 http://mirrors.163.com/ubuntu xenial-backports/multiverse DEP-11 64x64 Icons [29 B]                                                                                                                                                     
Fetched 53.4 MB in 18s (2,849 kB/s)                                                                                                                                                                                                             
AppStream cache update completed, but some metadata was ignored due to errors.
Reading package lists... Done

终于搞定啦

备注: 

最好把DNS设置一下

sudo vi /etc/resolv.conf 

在里面添加

nameserver 8.8.8.8

重启网络服务

sudo service networking restart

原文地址:https://www.cnblogs.com/gcgc/p/10131617.html