Ubuntu常见问题记录

Ubuntu常见问题记录

    • 查看系统信息
      • 查看本机内核驱动
      • 查看Opencv版本
    • 常用软件安装
      • 换成国内源
      • add-apt-repository(PPA)
      • ubuntu-drivers: command not found
      • 安装Opencv
    • apt-get相关
      • apt-get update -> E: Unable to lock directory /var/lib/apt/lists/
      • apt-get update -> 卡在Waiting for headers
      • bazel authentication failed
    • 其他错误
      • 运行shell脚本出现`%0D`编码

查看系统信息

查看本机内核驱动

$ cat /proc/driver/nvidia/version
NVRM version: NVIDIA UNIX x86_64 Kernel Module  450.102.04  Tue Dec 29 06:51:23 UTC 2020
GCC version:  gcc version 7.5.0 (Ubuntu 7.5.0-6ubuntu2)

查看Opencv版本

$ pkg-config --modversion opencv
2.4.9.1

常用软件安装

换成国内源

例如:清华源 https://mirrors.tuna.tsinghua.edu.cn/help/ubuntu/
换源之后可能的问题:

root@9ff72f3b6504:/etc/apt# apt-get update
Ign:1 https://mirrors.tuna.tsinghua.edu.cn/ubuntu bionic InRelease
Ign:2 https://mirrors.tuna.tsinghua.edu.cn/ubuntu bionic-updates InRelease
Ign:3 https://mirrors.tuna.tsinghua.edu.cn/ubuntu bionic-backports InRelease
Ign:4 https://mirrors.tuna.tsinghua.edu.cn/ubuntu bionic-security InRelease
Err:5 https://mirrors.tuna.tsinghua.edu.cn/ubuntu bionic Release
  Certificate verification failed: The certificate is NOT trusted. The certificate issuer is unknown.  Could not handshake: Error in the certificate verification. [IP: 101.6.8.193 443]
Err:6 https://mirrors.tuna.tsinghua.edu.cn/ubuntu bionic-updates Release
  Certificate verification failed: The certificate is NOT trusted. The certificate issuer is unknown.  Could not handshake: Error in the certificate verification. [IP: 101.6.8.193 443]
Err:7 https://mirrors.tuna.tsinghua.edu.cn/ubuntu bionic-backports Release
  Certificate verification failed: The certificate is NOT trusted. The certificate issuer is unknown.  Could not handshake: Error in the certificate verification. [IP: 101.6.8.193 443]
Err:8 https://mirrors.tuna.tsinghua.edu.cn/ubuntu bionic-security Release
  Certificate verification failed: The certificate is NOT trusted. The certificate issuer is unknown.  Could not handshake: Error in the certificate verification. [IP: 101.6.8.193 443]
Reading package lists... Done
W: https://mirrors.tuna.tsinghua.edu.cn/ubuntu/dists/bionic/InRelease: No system certificates available. Try installing ca-certificates.
W: https://mirrors.tuna.tsinghua.edu.cn/ubuntu/dists/bionic-updates/InRelease: No system certificates available. Try installing ca-certificates.
W: https://mirrors.tuna.tsinghua.edu.cn/ubuntu/dists/bionic-backports/InRelease: No system certificates available. Try installing ca-certificates.
W: https://mirrors.tuna.tsinghua.edu.cn/ubuntu/dists/bionic-security/InRelease: No system certificates available. Try installing ca-certificates.
W: https://mirrors.tuna.tsinghua.edu.cn/ubuntu/dists/bionic/Release: No system certificates available. Try installing ca-certificates.
E: The repository 'https://mirrors.tuna.tsinghua.edu.cn/ubuntu bionic Release' does not have a Release file.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
W: https://mirrors.tuna.tsinghua.edu.cn/ubuntu/dists/bionic-updates/Release: No system certificates available. Try installing ca-certificates.
E: The repository 'https://mirrors.tuna.tsinghua.edu.cn/ubuntu bionic-updates Release' does not have a Release file.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
W: https://mirrors.tuna.tsinghua.edu.cn/ubuntu/dists/bionic-backports/Release: No system certificates available. Try installing ca-certificates.
E: The repository 'https://mirrors.tuna.tsinghua.edu.cn/ubuntu bionic-backports Release' does not have a Release file.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
W: https://mirrors.tuna.tsinghua.edu.cn/ubuntu/dists/bionic-security/Release: No system certificates available. Try installing ca-certificates.
E: The repository 'https://mirrors.tuna.tsinghua.edu.cn/ubuntu bionic-security Release' does not have a Release file.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
root@9ff72f3b6504:/etc/apt# apt install ca-certificates
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package ca-certificates is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'ca-certificates' has no installation candidate

解决方案:
默认的源是http的,但替换用的镜像源是https,所以休要额外的安装关于HTTPS的包。

apt install apt-transport-https
apt install ca-certificates
apt update

参考:https://www.caorui.net/blog/103683375281209344.html

add-apt-repository(PPA)

如果没有装PPA,则会无法使用,会出现这样的错误。

root@9ff72f3b6504:/# add-apt-repository
bash: add-apt-repository: command not found

解决方案:

apt-get install software-properties-common

ubuntu-drivers: command not found

解决方法:

sudo apt-get install ubuntu-drivers-common

若安装后再次报错,如下:

root@9ff72f3b6504:/# ubuntu-drivers devices
Traceback (most recent call last):
  File "/usr/bin/ubuntu-drivers", line 480, in 
    greet()
  File "/usr/lib/python3/dist-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/click/core.py", line 676, in main
    _verify_python3_env()
  File "/usr/lib/python3/dist-packages/click/_unicodefun.py", line 118, in _verify_python3_env
    'for mitigation steps.' + extra)
RuntimeError: Click will abort further execution because Python 3 was configured to use ASCII as encoding for the environment.  Consult http://click.pocoo.org/python3/for mitigation steps.

This system supports the C.UTF-8 locale which is recommended.
You might be able to resolve your issue by exporting the
following environment variables:

    export LC_ALL=C.UTF-8
    export LANG=C.UTF-8

解决方案:

export LC_ALL=C.UTF-8
export LANG=C.UTF-8

安装Opencv

安装opencv报错

    Traceback (most recent call last):
      File "", line 1, in <module>
      File "/tmp/pip-build-nWnHUR/opencv-python/setup.py", line 9, in <module>
        import skbuild
    ImportError: No module named skbuild

解决方案:

pip install opencv-python==4.1.1.26 -i https://pypi.tuna.tsinghua.edu.cn/simple

运行代码,错误:

  File "/usr/local/lib/python2.7/dist-packages/skimage/util/__init__.py", line 7, in <module>
    from .arraycrop import crop
  File "/usr/local/lib/python2.7/dist-packages/skimage/util/arraycrop.py", line 8, in <module>
    from numpy.lib.arraypad import _validate_lengths
ImportError: cannot import name _validate_lengths

numpy版本太高,我对numpy进行了重新安装:

pip install numpy==1.15.0

参考:ImportError: cannot import name ‘_validate_lengths’

apt-get相关

apt-get update -> E: Unable to lock directory /var/lib/apt/lists/

在使用apt-get update时,出现如图错误。
在这里插入图片描述
解决方案:

rm /var/lib/apt/lists/lock

参考:在Ubuntu下解决E: 无法对目录 /var/lib/apt/lists/ 加锁的问题

apt-get update -> 卡在Waiting for headers

在使用apt-get update指令时,卡在了Waiting for headers不动。
在这里插入图片描述
解决方案:

rm /var/lib/apt/lists/*
rm /var/lib/apt/lists/partial/*
apt-get update

参考:apt-get update时卡在 waiting for headers

bazel authentication failed

安装tensorflow或caffe过程中,会安装bazel. 该处因为PPA key expired.

解决方案:

sudo apt install apt-transport-https curl gnupg
curl -fsSL https://bazel.build/bazel-release.pub.gpg | gpg --dearmor > bazel.gpg
sudo mv bazel.gpg /etc/apt/trusted.gpg.d/
echo "deb [arch=amd64] https://storage.googleapis.com/bazel-apt stable jdk1.8" | sudo tee /etc/apt/sources.list.d/bazel.list

参考:https://docs.bazel.build/versions/master/install-ubuntu.html#install-on-ubuntu

其他错误

运行shell脚本出现%0D编码

修改文件格式,vim打开设置如下

:set ff=unix

解决方案参考:https://www.jianshu.com/p/fe8ec5f5792d

你可能感兴趣的:(Linux,ubuntu,linux)