![curl 在 Ubuntu 18.04 LTS 上不起作用](https://linux22.com/image/1007239/curl%20%E5%9C%A8%20Ubuntu%2018.04%20LTS%20%E4%B8%8A%E4%B8%8D%E8%B5%B7%E4%BD%9C%E7%94%A8.png)
我无法使用 `curl 从网络获取内容。我尝试安装它并得到以下输出:
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies.
curl : Depends: libcurl4 (= 7.58.0-2ubuntu3) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
sudo apt-mark showheld
我已经使用和检查了保留的包裹dpkg -l | grep ^h
,但都没有得到结果。
另外,当我尝试安装时libcurl4
,它几乎破坏了我的系统,因为它试图删除这些包:
libcurl3 mongodb-enterprise mongodb-enterprise-server mongodb-enterprise-tools msodbcsql msodbcsql17 mssql-tools php7.1-curl r-base r-base-core
r-base-dev r-base-html r-cran-boot r-cran-class r-cran-codetools r-cran-foreign r-cran-getopt r-cran-kernsmooth r-cran-lattice r-cran-littler
r-cran-mass r-cran-matrix r-cran-mgcv r-cran-nlme r-cran-nnet r-cran-rpart r-cran-spatial r-cran-survival r-recommended slack-desktop
virtualbox-5.2
编辑
这是输出cat /etc/apt/sources.list
:
# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution. deb http://gb.archive.ubuntu.com/ubuntu/ bionic main restricted deb-src
http://gb.archive.ubuntu.com/ubuntu/ bionic main restricted
## Major bug fix updates produced after the final release of the
## distribution. deb http://gb.archive.ubuntu.com/ubuntu/ bionic-updates main restricted deb-src
http://gb.archive.ubuntu.com/ubuntu/ bionic-updates main restricted
## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team. Also, please note that software in universe WILL NOT receive any
## review or updates from the Ubuntu security team. deb http://gb.archive.ubuntu.com/ubuntu/ bionic universe deb-src
http://gb.archive.ubuntu.com/ubuntu/ bionic universe
deb http://gb.archive.ubuntu.com/ubuntu/ bionic-updates universe
deb-src http://gb.archive.ubuntu.com/ubuntu/ bionic-updates universe
## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team, and may not be under a free licence. Please satisfy yourself as to
## your rights to use the software. Also, please note that software in
## multiverse WILL NOT receive any review or updates from the Ubuntu
## security team. deb http://gb.archive.ubuntu.com/ubuntu/ bionic multiverse deb-src http://gb.archive.ubuntu.com/ubuntu/ bionic
multiverse
deb http://gb.archive.ubuntu.com/ubuntu/ bionic-updates multiverse
deb-src http://gb.archive.ubuntu.com/ubuntu/ bionic-updates multiverse
## N.B. software from this repository may not have been tested as
## extensively as that contained in the main release, although it includes
## newer versions of some applications which may provide useful features.
## Also, please note that software in backports WILL NOT receive any review
## or updates from the Ubuntu security team.
# deb-src http://gb.archive.ubuntu.com/ubuntu/ bionic-backports main restricted universe multiverse
## Uncomment the following two lines to add software from Canonical's
## 'partner' repository.
## This software is not part of Ubuntu, but is offered by Canonical and the
## respective vendors as a service to Ubuntu users. deb http://archive.canonical.com/ubuntu bionic partner deb-src
http://archive.canonical.com/ubuntu bionic partner
deb http://security.ubuntu.com/ubuntu bionic-security main restricted
deb-src http://security.ubuntu.com/ubuntu bionic-security main
restricted
deb http://security.ubuntu.com/ubuntu bionic-security universe deb-src
http://security.ubuntu.com/ubuntu bionic-security universe
deb http://security.ubuntu.com/ubuntu bionic-security multiverse
deb-src http://security.ubuntu.com/ubuntu bionic-security multiverse
deb http://gb.archive.ubuntu.com/ubuntu/ bionic-proposed main
multiverse universe restricted #Not for humans during development
stage of release bionic
# ded-src http://archive.ubuntu.com/ubuntu/ trusty-backports main restricted ui=niverse
deb http://gb.archive.ubuntu.com/ubuntu/ bionic-backports main
restricted multiverse universe
答案1
此问题在 ubuntu 近期 LTS 中的多个软件包中很常见。预安装的软件包在版本约定方面可能存在错误,因为“18.04”和其他引用 repo 的字符串被视为软件包版本的一部分,而不是对 repo 的引用。
解决方法是卸载预安装的依赖项,然后重新安装。之后,您可以安装 cURL。
apt remove -y libcurl4
apt install -y libcurl4 curl
存在该问题的其他软件包是 okular 和 libsdl2,解决方案相同,跟踪有问题的依赖项,删除并重新安装。
另外,您可以使用apt
降级机制(因此,不需要卸载依赖 libcurl4 的软件包)。
apt install -y libcurl4=7.58.0-2ubuntu3
apt install -y curl
答案2
安装从源头卷曲. 这对我有用。
git clone https://github.com/curl/curl.git
cd curl
./buildconf
./configure
make
make test # optional
sudo make install
答案3
尝试使用
sudo apt install libcurl4-openssl-dev
如果遇到任何错误,请尝试以下命令,然后再次尝试上述命令。
sudo apt update
sudo apt remove libcurl4
答案4
然后使用安装 libcurl4 sudo apt-get install libcurl4
,使用安装 curlsudo apt-get install curl
如果出现“未找到 CURL_OPENSSL_4 错误”,请使用以下命令删除“/usr/lib/x86_64-linux-gnu/libcurl.so.4”文件:
sudo rm /usr/lib/x86_64-linux-gnu/libcurl.so.4
使用以下命令再次创建软链接:
sudo ln -s /usr/lib/x86_64-linux-gnu/libcurl.so.4.5.0 /usr/lib/x86_64-linux-gnu/libcurl.so.4