前言
本博客记录自己使用ubuntu的一些错误和坑。
ubuntu不支持yum下载安装机制
- 命令 sudo apt install yum 是可以安装yum的,但安装好后执行:
$ yum install gcc
报错:
There are no enabled repos.
Run "yum repolist all" to see the repos you have.
You can enable repos with yum-config-manager --enable <repo>
- ubuntu不支持yum的下载安装机制,需要使用apt.
执行ubuntu 更新源出现错误:
Reading package lists… Done
E: Problem executing scripts APT::Update::Post-Invoke-Success ‘if /usr/bin/test -w /var/cache/app-info -a -e /usr/bin/appstreamcli; then appstreamcli refresh > /dev/null; fi’
E: Sub-process returned an error code
- 解决办法:
cd /tmp && mkdir asfix
cd asfix
wget https://launchpad.net/ubuntu/+archive/primary/+files/appstream_0.9.4-1ubuntu1_amd64.deb
wget https://launchpad.net/ubuntu/+archive/primary/+files/libappstream3_0.9.4-1ubuntu1_amd64.deb
sudo dpkg -i *.deb
- 重新update后问题解决;
ubuntu安装python3.6后pip命令错误
pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Could not fetch URL https:*******: There was a problem confirming the ssl certificate:
Can't connect to HTTPS URL because the SSL module is not available. - skipping
- 原因是缺少ssl模块。
sudo apt install openssl
sudo apt-get install libssl-dev
# 尝试在python交互窗口输入
import ssl
# 如果找不到那么要重新编译安装python
sudo ./configure --with-ssl
sudo make
sudo make install
# 如果提示找不到ssl先不用管,依旧编译安装。
# 最好在安装python版本前先安装openssl和libssl-dev
Ubuntu更新时提示错误 E: Sub-process /usr/bin/dpkg returned an error code (1)
按下面操作依次执行
$ sudo su //root权限
$ sudo mv /var/lib/dpkg/info /var/lib/dpkg/info_old //现将info文件夹更名
$ sudo mkdir /var/lib/dpkg/info //再新建一个新的info文件夹
//更新
$ sudo apt-get update
$ apt-get -f install
$ sudo mv /var/lib/dpkg/info/* /var/lib/dpkg/info_old
//执行完更新操作后会在info文件夹下生成一些文件,现将这些文件全部移到info_old文件夹下
$ sudo rm -rf /var/lib/dpkg/info // delete新建的info文件夹
$ sudo mv /var/lib/dpkg/info_old /var/lib/dpkg/info //把以前的info文件夹重新改回名字
sudo mv /var/lib/dpkg/info /var/lib/dpkg/info_old
sudo mkdir /var/lib/dpkg/info
sudo apt-get update
apt-get -f install
sudo mv /var/lib/dpkg/info/* /var/lib/dpkg/info_old
sudo rm -rf /var/lib/dpkg/info
sudo mv /var/lib/dpkg/info_old /var/lib/dpkg/info
Ubuntu安装redis是指定make test报错:You need tcl 8.5 or newer in order to run the Redis test
# 需要更新tcl到更高的版本
wget http://downloads.sourceforge.net/tcl/tcl8.6.1-src.tar.gz
sudo tar xzvf tcl8.6.1-src.tar.gz -C /usr/local/
cd /usr/local/tcl8.6.1/unix/
sudo ./configure
sudo make
sudo make install
Ubuntu安装报错:update-rc.d: error: insserv rejected the script header
# 一般是配置文件设置死循环带来的错误
先将/etc/init.d中的程序启动文件移动到其他的位置,然后重新执行
apt install xxx
最后将启动文件移动回/etc/init.d文件夹中
Ubuntu提示:/etc/init.d/functions: No such file or directory
functions这个脚本是给/etc/init.d里边的文件使用的。提供了一些基础的功能,但是Ubuntu16.04默认/etc/init.d/目录下不带这个文件,
其实这个文件在/lib/apparmor/目录下,设置一个软连接到/etc/init.d/就可以解决这个问题。
ln -s /lib/apparmor/functions /etc/init.d/functions
ubuntu其pip后出现ImportError: cannot import name main
- 修改pip文件
将pip文件:
from pip._internal import main
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
sys.exit(main())
改为:
from pip import __main__
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
sys.exit(__main__._main())
# 退出就可以正常使用了