ubuntu or debian:
安装zlib包并不是apt-get install zlib
而是用
apt-get install zlib1g-dev
此提示为缺少库文件,安装即可,ubuntu下安装方法:
sudo apt-get install zlib1g-dev libssl-dev
但有時 apt-get update 或 install 失敗時會報錯,有时候会出现无法获得锁的权限问题。这是因为有另外一个进程在占用锁。
(rna) lchen@lchen-Vostro-5460:/etc/apt/sources.list.d$ apt-get update
Reading package lists... Done
E: Could not open lock file /var/lib/apt/lists/lock - open (13: Permission denied)
E: Unable to lock directory /var/lib/apt/lists/
W: Problem unlinking the file /var/cache/apt/pkgcache.bin - RemoveCaches (13: Permission denied)
W: Problem unlinking the file /var/cache/apt/srcpkgcache.bin - RemoveCaches (13: Permission denied)
解決方法:
sudo rm -rf /var/lib/apt/lists/lock
或報錯如
```bash
Get:192 https://mirrors.tuna.tsinghua.edu.cn/ubuntu bionic-security/multiverse DEP-11 64x64 Icons [2,638 B]
Fetched 110 MB in 38s (2,945 kB/s)
Reading package lists... Done
E: Could not open lock file /var/lib/dpkg/lock-frontend - open (13: Permission denied)
E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), are you root?
(rna) lchen@lchen-Vostro-5460:/etc/apt/sources.list.d$ sudo rm -rf /var/lib/dpkg/lock-frontend
(rna) lchen@lchen-Vostro-5460:/etc/apt/sources.list.d$ sudo rm -rf /var/cache/apt/archives/lock
(rna) lchen@lchen-Vostro-5460:/etc/apt/sources.list.d$ sudo apt-get update
Hit:1 http://mirrors.aliyun.com/ubuntu bionic InRelease
Hit:2 http://mirrors.aliyun.com/ubuntu bionic-security InRelease
Hit:3 http://mirrors.aliyun.com/ubuntu bionic-updates InRelease
Hit:4 http://mirrors.aliyun.com/ubuntu bionic-proposed InRelease
Hit:5 http://mirrors.aliyun.com/ubuntu bionic-backports InRelease
Hit:6 https://mirrors.tuna.tsinghua.edu.cn/ubuntu bionic InRelease
Hit:7 https://mirrors.tuna.tsinghua.edu.cn/ubuntu bionic-updates InRelease
Hit:8 https://mirrors.tuna.tsinghua.edu.cn/ubuntu bionic-backports InRelease
Hit:9 https://mirrors.tuna.tsinghua.edu.cn/ubuntu bionic-security InRelease
Reading package lists... Done
(rna) lchen@lchen-Vostro-5460:/etc/apt/sources.list.d$ sudo dpkg --configure -a
(rna) lchen@lchen-Vostro-5460:/etc/apt/sources.list.d$
再次更新失敗的話,進行下一步:
1、找到并且杀掉所有的apt-get 和apt进程
运行下面的命令来生成所有含有 apt 的进程列表,你可以使用ps和grep命令并用管道组合来得到含有apt或者apt-get的进程。
ps -A | grep apt
找出所有的 apt 以及 apt-get 进程
sudo kill -9 processnumber
再次删除锁定文件
一旦运行了 apt-get 或者 apt 命令,锁定文件将会创建于 /var/lib/apt/lists/、/var/lib/dpkg/、/var/cache/apt/archives/ 中。
sudo rm /var/lib/dpkg/lock
强制重新配置软件包:
sudo rm /var/lib/apt/lists/lock
sudo apt-get update