本篇記錄:重裝系統記錄中間會遇到的一些細節問題與參考解決方式
*******************************************************************
*******************************************************************
【問題1】中斷一些更新,再執行其他程序時,會遇到
E: Could not get lock /var/lib/dpkg/lock - open (11: Resource temporarily unavailable)
E: Unable to lock the administration directory (/var/lib/dpkg/), is another process using it?
E: Could not get lock /var/lib/apt/lists/lock - open (11: Resource temporarily unavailable)
E: Unable to lock directory /var/lib/apt/lists/
E: Could not get lock /var/lib/apt/lists/lock - open (11: Resource temporarily unavailable)
E: Unable to lock directory /var/lib/apt/lists/
【解決】
方式一:
$ sudo rm /var/lib/apt/lists/lock
$ sudo rm /var/cache/apt/archives/lock
$ sudo rm /var/lib/dpkg/lock
方式二:
1、運行下面的命令來生成所有含有 apt 的進程列表
命令:ps -A | grep apt
2、殺死進程
命令:kill -9 2814
*******************************************************************
*******************************************************************
【問題2】sudo apt-get update特別慢更新不了
【解決】
打開terminal,備份原文件
sudo cp /etc/apt/sources.list /etc/apt/sources.list.old
cd /etc/apt
sudo gedit sources.list
(sudo gedit /etc/apt/sources.list )
添加如下內容【去阿里雲上 https://developer.aliyun.com/mirror/ubuntu,查看適合 ubuntu 16.04 的源配置如下】:
deb http://mirrors.aliyun.com/ubuntu/ xenial main
deb-src http://mirrors.aliyun.com/ubuntu/ xenial main
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main
deb http://mirrors.aliyun.com/ubuntu/ xenial universe
deb-src http://mirrors.aliyun.com/ubuntu/ xenial universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates universe
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-security main
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main
deb http://mirrors.aliyun.com/ubuntu/ xenial-security universe
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security universe
也可參考@ https://www.cnblogs.com/Eric-Shenblog/p/10862027.html
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
然后:
sudo apt-get update #更新軟件列表。
sudo apt-get upgrate #更新軟件。這一步,如果按提示選擇了Y,可能會耗時很長,耐心等待。
@ https://www.cnblogs.com/X-knight/p/10598498.html
如何更改源:東北大學、清華大學、阿里雲
*******************************************************************
*******************************************************************
【問題3】sudo apt-get update 報錯
Get:103 http://mirrors.aliyun.com/ubuntu bionic-backports/universe DEP-11 64x64 Icons [29 B]
Fetched 58.6 MB in 8s (6,754 kB/s)
(appstreamcli:8043): GLib-CRITICAL **: g_strchug: assertion 'string != NULL' failed
(appstreamcli:8043): GLib-CRITICAL **: g_strchomp: assertion 'string != NULL' failed
(appstreamcli:8043): GLib-CRITICAL **: g_strchug: assertion 'string != NULL' failed
(appstreamcli:8043): GLib-CRITICAL **: g_strchomp: assertion 'string != NULL' failed
(appstreamcli:8043): GLib-CRITICAL **: g_strchug: assertion 'string != NULL' failed
(appstreamcli:8043): GLib-CRITICAL **: g_strchomp: assertion 'string != NULL' failed
AppStream cache update completed, but some metadata was ignored due to errors.
Reading package lists... Done
Building dependency tree
Reading state information... Done
1490 packages can be upgraded. Run 'apt list --upgradable' to see them.
【解決】
解決辦法1:
sudo sed -i -e 's/bionic/xenial/g' /etc/apt/sources.list
@https://www.cnblogs.com/iBoundary/p/12679186.html
解決辦法2:
sudo apt purge libappstream4
@https://blog.csdn.net/qq_41972382/article/details/95720761
@https://blog.csdn.net/zhushixia1989/article/details/104550890/
*******************************************************************
*******************************************************************
【問題4】sudo apt-get install XXX 時, 會出現 E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
【解決】
解決辦法1:源的問題,更改后更新,參考“【問題2】sudo apt-get update特別慢更新不了”
解決辦法2:網絡的問題
網關錯誤攔截了數據包或者防火牆故意將其屏蔽在外(比方update 包含有google-chrome瀏覽器的source時候,ip 會自動重定向至6.6.6.6)
sudo gedit /etc/resolv.conf
添加:
nameserver 8.8.8.8
nameserver 223.5.5.5
nameserver 223.6.6.6
@ https://www.cnblogs.com/X-knight/p/10598076.html
*******************************************************************
*******************************************************************
【問題5】sudo apt-get install XXX 安裝不好使的時候,使用sudo aptitude install XXX,也可以在 source.list 中更新國內源
【解決】
sudo apt-get install iptux
sudo apt-get install aptitude
Ubuntu如何更新軟件源@ https://jingyan.baidu.com/article/624e74590223bc34e8ba5a3b.html
*******************************************************************
*******************************************************************
【問題5】Ubuntu 16.04安裝iBus中文輸入法pinyin及問題
【解決】@ https://blog.csdn.net/suifenghahahaha/article/details/78723733
*******************************************************************
*******************************************************************
【問題6】如果系統的內核不是最新的,如何更新到最新穩定版本的內核?
【解決】
Ubuntu 18.04 LTS - Bionic Beaver
DESKTOP:
sudo apt-get install --install-recommends linux-generic-hwe-18.04 xserver-xorg-hwe-18.04
SERVER:
sudo apt-get install --install-recommends linux-generic-hwe-18.04
Ubuntu 16.04 LTS - Xenial Xerus
DESKTOP
sudo apt-get install --install-recommends linux-generic-hwe-16.04 xserver-xorg-hwe-16.04
SERVER
sudo apt-get install --install-recommends linux-generic-hwe-16.04
@https://blog.csdn.net/wangweiwells/java/article/details/88279537
*******************************************************************
*******************************************************************
【問題7】禁止更新內核,需時間來驗證
sudo apt-mark hold linux-image-x.xx.x-xx-generic
sudo apt-mark hold linux-image-extra-x.xx.x-xx-generic
【解決】
sudo apt-mark hold linux-image-4.15.0-96-generic
sudo apt-mark hold linux-image-extra-4.15.0-96-generic
sudo apt-mark hold linux-modules-extra-4.15.0-96-generic
u@u1604:~$ sudo apt-mark hold linux-image-extra-4.15.0-96-generic
E: 無法定位軟件包 linux-image-extra-4.15.0-96-generic
E: 無法按照 glob ‘linux-image-extra-4.15.0-96-generic’ 找到任何軟件包
E: 無法按照正則表達式 linux-image-extra-4.15.0-96-generic 找到任何軟件包
E: 沒有發現匹配的軟件包
sudo apt-get install linux-image-extra-4.15.0-96-generic
一條語句禁止內核更新:
sudo apt-mark hold linux-image-4.15.0-96-generic linux-modules-extra-4.15.0-96-generic linux-headers-4.15.0-96-generic
*******************************************************************
*******************************************************************
【問題8】安裝新內核
1. 執行以下命令安裝
sudo apt-get install linux-image-extra-4.15.0-96-generic
2. 執行以下命令查看是否安裝成功
dpkg -l | grep 4.15.0-96-generic
3. 保存退出,然后執行以下命令更新 Grub 引導
sudo update-grub
4.將其他版本的內核刪除,如(對deinstall的需要用dpkg卸載):
sudo apt-get remove linux-headers-4.15.0-33
sudo dpkg -P linux-image-4.8.0-36-generic
sudo apt-get purge linux-image-<版本號> 命令
5.查看Linux中當前使用的內核:
使用 uname -a 或者 uname -r 命令
6.查看Linux中安裝了哪些內核:
使用 dpkg --get-selections | grep linux 或者 dpkg --list |grep linux 命令
7.需要知道的是,內核映像文件主要包括以下類型:
linux-image-版本號:內核映像文件
linux-headers-版本號:內核頭文件
linux-image-extra-版本號:內核擴展文件
8.更新grub文件:
sudo update-grub
-----------------------------------------------
安裝的話,需要注意,安裝內核需要安裝image和header,不能只安裝其中一個。
比如我現在安裝一個linux-image-4.8.0-58-generic,
就必須還要安裝一個linux-headers-4.8.0-58-generic。
sudo apt-get install linux-image-4.15.0-88-generic
sudo apt-get install linux-headers-4.15.0-88-generic
sudo apt-get install linux-image-extra-4.15.0-88-generic
sudo apt-get install linux-modules-extra-4.15.0-96-generic
sudo apt-get install linux-image-4.15.0-88-generic linux-headers-4.15.0-88-generic
*******************************************************************
*******************************************************************
【問題9】opencv的下載與編譯
【(1)下載】
https://github.com/opencv/opencv/archive/3.4.2.zip
wget -c https://github.com/opencv/opencv/archive/3.4.2.zip
wget -c https://github.com/opencv/opencv_contrib/archive/3.4.2.zip
注意:下載的是同名,但是不同的文件,在不同的文件里進行下載並解壓。
【(2)編譯】
sudo apt-get install build-essential
sudo apt-get install cmake git libgtk2.0-dev ffmpeg libopencv-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev libavcodec-dev libavformat-dev libswscale-dev libv4l-dev liblapacke-dev libxvidcore-dev libx264-dev libatlas-base-dev gfortran
cd opencv-3.4.2
mkdir build && cd build
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON-D WITH_TBB=ON -D WITH_V4L=ON -D WITH_QT=ON -D WITH_OPENGL=ON -D OPENCV_EXTRA_MODULES_PATH=/home/u/opencv-3.4.2/opencv_contrib-3.4.2/modules -D BUILD_EXAMPLES=ON ..
sudo make (sudo make all -j12 加快速度)
sudo make install
-------------------------
[100%] Linking CXX executable ../../bin/example_tutorial_display_image
[100%] Built target example_tutorial_cloning_gui
[100%] Linking CXX executable ../../bin/example_cpp_openni_capture
[100%] Built target example_tutorial_display_image
[100%] Built target example_cpp_openni_capture
[100%] Linking CXX shared module ../../lib/cv2.so
[100%] Built target opencv_python2
u@u1604:~/opencv-3.4.2/build$
u@u1604:~/opencv-3.4.2/build$
u@u1604:~/opencv-3.4.2/build$
u@u1604:~/opencv-3.4.2/build$ sudo make install
【(2)編譯---會遇到的細節問題】
cmake -D ...........
(1)CMake Error at /usr/share/cmake-3.5/Modules/FindQt4.cmake:1326 (message):
Found unsuitable Qt version "" from NOTFOUND, this code requires Qt 4.x
sudo apt-get install qt4-default
重新編譯,即可成功``。
或者:
用QT5編譯
```py
catkin_make -DUseQt5=ON -j2
(2)解決GitHub的raw.githubusercontent.com無法連接問題 @https://www.cnblogs.com/sinferwu/p/12726833.html
sudo gedit /etc/hosts
# wp2020.4.23 for opencv-sudo-make error of boostdesc_bgm.i
#151.101.76.133 raw.githubusercontent.com
199.232.68.133 raw.githubusercontent.com
iP或域名查詢
raw.githubusercontent.com服務器iP:
當前解析:
日本 東京 151.101.108.133
日本 東京 151.101.228.133
美國 151.101.0.133
保留地址 0.0.0.0
中國 香港 151.101.76.133
歷史解析記錄:
2017-04-13-----2020-04-23 151.101.76.133
2017-12-14-----2020-04-23 151.101.228.133
2018-10-11-----2020-04-23 151.101.108.133
*******************************************************************
*******************************************************************
【問題10】python2 與 python3 的切換
update-alternatives --list python
update-alternatives --install /usr/bin/python python /usr/bin/python2.7 1
update-alternatives --install /usr/bin/python python /usr/bin/python3.5 2
update-alternatives --list python
update-alternatives --config python
*******************************************************************
*******************************************************************
【問題11】執行python3 -m pip install 模塊名 、sudo pip3 install XXX,
會提示:from pip import main ImportError: cannot import name 'main'
u@u1604:~$ sudo pip3 install -r requirements/requirements-linux-python3.txt
Traceback (most recent call last):
File "/usr/bin/pip3", line 9, in <module>
from pip import main
ImportError: cannot import name 'main'
【解決】
sudo gedit /usr/bin/pip3
#!/usr/bin/python3
# GENERATED BY DEBIAN
import sys
# Run the main entry point, similarly to how setuptools does it, but because
# we didn't install the actual entry point from setup.py, don't use the
# pkg_resources API.
# python2
'''
from pip import main
if __name__ == '__main__':
sys.exit(main())
'''
# python3
from pip import __main__
if __name__ == '__main__':
sys.exit(__main__._main())
*******************************************************************
*******************************************************************
安裝完后,查看細節版本:
(1)查看NVIDIA驅動安裝版本
驗證是否安裝成功,執行:nvidia-smi 。
(2)查看CUDA安裝版本
CUDA一般安裝在 /usr/local/cuda/ 路徑下,該路徑下有一個version.txt文檔,里面記錄了cuda的版本信息。
執行命令:cat /usr/local/cuda/version.txt ,即可查詢。
也可以使用:nvcc --version ,進行查詢。
(3)查看CuDNN版本
CuDNN的信息在其頭文件里:
cat /usr/local/cuda/include/cudnn.h | grep CUDNN_MAJOR -A 2 , 即可查詢。
(4)查詢OpenCV版本 :
pkg-config opencv --modversion
(5)查詢當前使用的kernel版本 :
uname -r
(6)查詢python版本 :
python
(6)查詢gcc版本 :
gcc --version