Ubuntu的apt-file解决依赖问题

前端之家收集整理的这篇文章主要介绍了Ubuntu的apt-file解决依赖问题前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

文章作者:Tyan
博客noahsnail.com | CSDN | 简书

1. 背景

平常我们在安装应用时,经常会碰到缺少各种文件、依赖等问题,例如缺少.so文件。Ubuntu中提供了一个强大的工具apt-file来查找依赖。最适合的场景是在Docker中使用,因为Docker Image的系统通常是Ubuntu。

2. 安装

apt-file的安装命令如下:

# Install
$ apt-get update
$ apt-get install apt-file

# Update apt-file
$ apt-file update

3. 搜索缺少的文件

如果缺少cv.py文件,则搜索cv.py文件apt-file会列出包含cv.py的包,发现需要的包是python-opencv,然后安装ython-opencv

# 命令格式
$ apt-file seach [filename]

# Demo
$ apt-file search cv.py
gnuradio: /usr/lib/python2.7/dist-packages/gnuradio/analog/wfm_rcv.py
gnuradio: /usr/share/gnuradio/examples/uhd/usrp_am_mw_rcv.py
gnuradio: /usr/share/gnuradio/examples/uhd/usrp_nbfm_rcv.py
gnuradio: /usr/share/gnuradio/examples/uhd/usrp_tv_rcv.py
gnuradio: /usr/share/gnuradio/examples/uhd/usrp_wfm_rcv.py
gnuradio: /usr/share/gnuradio/examples/uhd/usrp_wxapt_rcv.py
libqpid-proton2-dev-examples: /usr/share/proton-0.10/examples/python/db_recv.py
libqpid-proton2-dev-examples: /usr/share/proton-0.10/examples/python/direct_recv.py
libqpid-proton2-dev-examples: /usr/share/proton-0.10/examples/python/messenger/recv.py
libqpid-proton2-dev-examples: /usr/share/proton-0.10/examples/python/reactor/recv.py
libqpid-proton2-dev-examples: /usr/share/proton-0.10/examples/python/selected_recv.py
libqpid-proton2-dev-examples: /usr/share/proton-0.10/examples/python/simple_recv.py
libqpid-proton2-dev-examples: /usr/share/proton-0.10/examples/python/tx_recv.py
lowpan-test-tools: /usr/lib/x86_64-linux-gnu/lowpan-tools/test_recv.py
python-kivy: /usr/lib/python2.7/dist-packages/kivy/core/camera/camera_opencv.py
python-mvpa2-doc: /usr/share/doc/python-mvpa2-doc/examples/nested_cv.py
python-opencv: /usr/lib/python2.7/dist-packages/cv.py
python-pyavm: /usr/lib/python2.7/dist-packages/pyavm/cv.py
python-pysnmp4: /usr/lib/python2.7/dist-packages/pysnmp/entity/rfc3413/ntfrcv.py
python-pysnmp4: /usr/share/pyshared/pysnmp/entity/rfc3413/ntfrcv.py
python-pysnmp4-doc: /usr/share/doc/python-pysnmp4-doc/examples/v1arch/manager/ntfrcv.py
python-scapy: /usr/lib/python2.7/dist-packages/scapy/sendrecv.py
python-scapy: /usr/share/pyshared/scapy/sendrecv.py
python3-kivy: /usr/lib/python3/dist-packages/kivy/core/camera/camera_opencv.py
python3-pyavm: /usr/lib/python3/dist-packages/pyavm/cv.py
python3-pysnmp4: /usr/lib/python3/dist-packages/pysnmp/entity/rfc3413/ntfrcv.py

4. 列出包中的文件

查看python-opencv中的文件

# 命令格式
$ apt-file list [package name]

# Demo
$ apt-file list python-opencv
python-opencv: /usr/lib/python2.7/dist-packages/cv.py
python-opencv: /usr/lib/python2.7/dist-packages/cv2.x86_64-linux-gnu.so
python-opencv: /usr/share/doc/python-opencv/changelog.Debian.gz
python-opencv: /usr/share/doc/python-opencv/copyright
python-opencv-apps: /usr/lib/python2.7/dist-packages/opencv_apps/__init__.py
python-opencv-apps: /usr/lib/python2.7/dist-packages/opencv_apps/cfg/CamShiftConfig.py
python-opencv-apps: /usr/lib/python2.7/dist-packages/opencv_apps/cfg/ContourMomentsConfig.py
python-opencv-apps: /usr/lib/python2.7/dist-packages/opencv_apps/cfg/ConvexHullConfig.py
python-opencv-apps: /usr/lib/python2.7/dist-packages/opencv_apps/cfg/EdgeDetectionConfig.py
python-opencv-apps: /usr/lib/python2.7/dist-packages/opencv_apps/cfg/FBackFlowConfig.py
python-opencv-apps: /usr/lib/python2.7/dist-packages/opencv_apps/cfg/FaceDetectionConfig.py
python-opencv-apps: /usr/lib/python2.7/dist-packages/opencv_apps/cfg/FindContoursConfig.py
python-opencv-apps: /usr/lib/python2.7/dist-packages/opencv_apps/cfg/GeneralContoursConfig.py
python-opencv-apps: /usr/lib/python2.7/dist-packages/opencv_apps/cfg/GoodfeatureTrackConfig.py
python-opencv-apps: /usr/lib/python2.7/dist-packages/opencv_apps/cfg/HoughCirclesConfig.py
python-opencv-apps: /usr/lib/python2.7/dist-packages/opencv_apps/cfg/HoughLinesConfig.py
python-opencv-apps: /usr/lib/python2.7/dist-packages/opencv_apps/cfg/LKFlowConfig.py
python-opencv-apps: /usr/lib/python2.7/dist-packages/opencv_apps/cfg/PeopleDetectConfig.py
python-opencv-apps: /usr/lib/python2.7/dist-packages/opencv_apps/cfg/PhaseCorrConfig.py
python-opencv-apps: /usr/lib/python2.7/dist-packages/opencv_apps/cfg/SegmentObjectsConfig.py
python-opencv-apps: /usr/lib/python2.7/dist-packages/opencv_apps/cfg/SimpleFlowConfig.py
python-opencv-apps: /usr/lib/python2.7/dist-packages/opencv_apps/cfg/WatershedSegmentationConfig.py
python-opencv-apps: /usr/lib/python2.7/dist-packages/opencv_apps/cfg/__init__.py
python-opencv-apps: /usr/lib/python2.7/dist-packages/opencv_apps/msg/_Circle.py
python-opencv-apps: /usr/lib/python2.7/dist-packages/opencv_apps/msg/_CircleArray.py
python-opencv-apps: /usr/lib/python2.7/dist-packages/opencv_apps/msg/_CircleArrayStamped.py
python-opencv-apps: /usr/lib/python2.7/dist-packages/opencv_apps/msg/_Contour.py
python-opencv-apps: /usr/lib/python2.7/dist-packages/opencv_apps/msg/_ContourArray.py
python-opencv-apps: /usr/lib/python2.7/dist-packages/opencv_apps/msg/_ContourArrayStamped.py
python-opencv-apps: /usr/lib/python2.7/dist-packages/opencv_apps/msg/_Face.py
python-opencv-apps: /usr/lib/python2.7/dist-packages/opencv_apps/msg/_FaceArray.py
python-opencv-apps: /usr/lib/python2.7/dist-packages/opencv_apps/msg/_FaceArrayStamped.py
python-opencv-apps: /usr/lib/python2.7/dist-packages/opencv_apps/msg/_Flow.py
python-opencv-apps: /usr/lib/python2.7/dist-packages/opencv_apps/msg/_FlowArray.py
python-opencv-apps: /usr/lib/python2.7/dist-packages/opencv_apps/msg/_FlowArrayStamped.py
python-opencv-apps: /usr/lib/python2.7/dist-packages/opencv_apps/msg/_FlowStamped.py
python-opencv-apps: /usr/lib/python2.7/dist-packages/opencv_apps/msg/_Line.py
python-opencv-apps: /usr/lib/python2.7/dist-packages/opencv_apps/msg/_LineArray.py
python-opencv-apps: /usr/lib/python2.7/dist-packages/opencv_apps/msg/_LineArrayStamped.py
python-opencv-apps: /usr/lib/python2.7/dist-packages/opencv_apps/msg/_Moment.py
python-opencv-apps: /usr/lib/python2.7/dist-packages/opencv_apps/msg/_MomentArray.py
python-opencv-apps: /usr/lib/python2.7/dist-packages/opencv_apps/msg/_MomentArrayStamped.py
python-opencv-apps: /usr/lib/python2.7/dist-packages/opencv_apps/msg/_Point2D.py
python-opencv-apps: /usr/lib/python2.7/dist-packages/opencv_apps/msg/_Point2DArray.py
python-opencv-apps: /usr/lib/python2.7/dist-packages/opencv_apps/msg/_Point2DArrayStamped.py
python-opencv-apps: /usr/lib/python2.7/dist-packages/opencv_apps/msg/_Point2DStamped.py
python-opencv-apps: /usr/lib/python2.7/dist-packages/opencv_apps/msg/_Rect.py
python-opencv-apps: /usr/lib/python2.7/dist-packages/opencv_apps/msg/_RectArray.py
python-opencv-apps: /usr/lib/python2.7/dist-packages/opencv_apps/msg/_RectArrayStamped.py
python-opencv-apps: /usr/lib/python2.7/dist-packages/opencv_apps/msg/_RotatedRect.py
python-opencv-apps: /usr/lib/python2.7/dist-packages/opencv_apps/msg/_RotatedRectArray.py
python-opencv-apps: /usr/lib/python2.7/dist-packages/opencv_apps/msg/_RotatedRectArrayStamped.py
python-opencv-apps: /usr/lib/python2.7/dist-packages/opencv_apps/msg/_RotatedRectStamped.py
python-opencv-apps: /usr/lib/python2.7/dist-packages/opencv_apps/msg/_Size.py
python-opencv-apps: /usr/lib/python2.7/dist-packages/opencv_apps/msg/__init__.py
python-opencv-apps: /usr/share/doc/python-opencv-apps/changelog.Debian.gz
python-opencv-apps: /usr/share/doc/python-opencv-apps/copyright

5. 其它系统

在其它系统中,例如CentOS中,可以用yum whatprovides命令来查询命令所在的包。

猜你在找的Ubuntu相关文章