TX2更新源失敗的問題
TX2的軟體源為國外伺服器,網速會很慢,需要換國內的ARM源。
備份/etc/lib路徑下的source.list檔案,然後在終端(按ctrl+alt+T開啟)執行以下命令:
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak #為防止誤操作後無法恢復,先備份原檔案sources.list
sudo vim /etc/apt/sources.list #開啟sources.list,將原來的內容使用”#”符號全部註釋掉,然後在檔案結尾出新增中國科學技術大學或清華的源
將檔案改為國內源(注意修改之前先將原檔案備份),還有一點要注意,換源需要換ARM的源,不要換成了pc平臺的軟體源。這裡推薦兩個國內源,將原來檔案裡面的內容全部替換成下面兩個源之一就可以:
清華源:
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ xenial-updates main restricted universe multiverse
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ xenial-updates main restricted universe multiverse
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ xenial-security main restricted universe multiverse
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ xenial-security main restricted universe multiverse
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ xenial-backports main restricted universe multiverse
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ xenial-backports main restricted universe multiverse
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ xenial main universe restricted
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ xenial main universe restricted
科大的源:
deb http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-updates main restricted universe multiverse
deb-src http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-updates main restricted universe multiverse
deb http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-security main restricted universe multiverse
deb-src http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-security main restricted universe multiverse
deb http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-backports main restricted universe multiverse
deb-src http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-backports main restricted universe multiverse
deb http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial main universe restricted
deb-src http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial main universe restricted
替換之後,執行
sudo apt-get update
更新源,然後會打印出來一堆錯誤,如下圖所示
這是一個是GPG錯誤,下列簽名無法驗證,我們需要獲取系統中的這個公鑰,從資訊中獲取金鑰號,比如上面這個錯誤,金鑰號是F60F4B3D7FA2AF80,執行
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 68980A0EA10B4DE8(此處金鑰號要與錯誤提示中的一致)
後再次執行
sudo apt-get update
。
TX2自身的Linux系統自帶了opencv,不過由於版本比較低是2.4.13,而我又需要使用opencv的GPU加速功能,雖然opencv2.4.13已經支援GPU加速,但是3.0以下的opencv對GPU加速的支援不是很好,使用起來很麻煩,於是便想著在TX2上安裝opencv3.4。安裝opencv之前需要安裝依賴庫,由此牽出來了一大堆問題。
首先需要換源,TX2預設的Ubuntu的源下載速度太慢,可以通過替換
/etc/lib/apt/sources.list
檔案改為國內源(注意修改之前先將原檔案備份),還有一點要注意,換源需要換ARM的源,不要換成了pc平臺的軟體源。這裡推薦兩個國內源,將原來檔案裡面的內容全部替換成下面兩個源之一就可以:
deb http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial main multiverse restricted universe
deb http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-backports main multiverse restricted universe
deb http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-proposed main multiverse restricted universe
deb http://mirrors.ustc.edu.cn/ubuntu-ports xenial-security main multiverse restricted universe
deb http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-updates main multiverse restricted universe
deb-src http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial main multiverse restricted universe
deb-src http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-backports main multiverse restricted universe
deb-src http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-proposed main multiverse restricted universe
deb-src http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-security main multiverse restricted universe
deb-src http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-updates main multiverse restricted universe
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ xenial-updates main restricted universe multiverse
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ xenial-updates main restricted universe multiverse
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ xenial-security main restricted universe multiverse
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ xenial-security main restricted universe multiverse
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ xenial-backports main restricted universe multiverse
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ xenial-backports main restricted universe multiverse
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ xenial main universe restricted
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ xenial main universe restricted
清華源:
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ xenial-updates main restricted universe multiverse
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ xenial-updates main restricted universe multiverse
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ xenial-security main restricted universe multiverse
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ xenial-security main restricted universe multiverse
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ xenial-backports main restricted universe multiverse
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ xenial-backports main restricted universe multiverse
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ xenial main universe restricted
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ xenial main universe restricted
和科大的源:
deb http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-updates main restricted universe multiverse
deb-src http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-updates main restricted universe multiverse
deb http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-security main restricted universe multiverse
deb-src http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-security main restricted universe multiverse
deb http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-backports main restricted universe multiverse
deb-src http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-backports main restricted universe multiverse
deb http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial main universe restricted
deb-src http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial main universe restricted
替換之後,執行
sudo apt-get update
更新源,然後打印出來一堆錯誤,主要問題有兩個。
其中一個是GPG錯誤: 下列簽名無法驗證,錯誤的情況是這樣的
W: GPG error: http://repo.mate-desktop.org saucy InRelease: The following signatures couldn’t be verified because the public key is not available: NO_PUBKEY 68980A0EA10B4DE8
我們需要獲取系統中的這個公鑰,從資訊中獲取金鑰號,比如上面這個錯誤,金鑰號是68980A0EA10B4DE8,執行
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 68980A0EA10B4DE8
後再次更新,這個錯誤消失,不過還有一個錯誤,錯誤的列印如下:
E: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/xenial/main/binary-arm64/Packages 404 Not Found [IP: 91.189.88.161 80]
E: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/xenial-updates/main/binary-i386/Packages 404 Not Found [IP: 91.189.88.161 80]
E: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/xenial-backports/main/binary-i386/Packages 404 Not Found [IP: 91.189.88.161 80]
E: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/xenial-security/main/binary-i386/Packages 404 Not Found [IP: 91.189.88.161 80]
這裡顯示是91.189.161.80這個IP無法訪問,但是我用瀏覽器訪問了一下這個ip發現是可以訪問的,Ubuntu下所有的開源專案都在這裡了,於是我按照log上的目錄依次往下查詢,到
archive.ubuntu.com/ubuntu/dists/xenial-backports/main/
這個目錄之後,發現這個目錄下面沒有binary-i386這個目錄,好了,問題找到了,那麼是什麼原因導致的更新源時程式會訪問這個本來不存在的目錄呢。網上查詢一番後,找到一個比較關鍵的問題,在終端執行
dpkg --print-architecture
檢視當前CPU的架構,然後列印如下:
終端執行
dpkg --print-foreign-architectures
檢視設定的多架構支援,列印如下
發現多架構支援被設定了i386,然而我們的平臺是ARM架構的,不需要x86平臺的支援,先前的問題可能就是這個原因導致的,於是嘗試刪除這個設定
sudo dpkg --remove-architecture i386
然後更新源
sudo apt-get update
成功!更新源成功之後就可以安裝opencv的依賴,然後安裝opencv了。
主要參考:
[1] Ubuntu更新錯誤修復大全:http://www.linuxidc.com/Linux/2015-06/118678.htm
[2] https://askubuntu.com/questions/917081/how-to-get-rid-of-arm64-in-apt#