1. 程式人生 > >Python 如何根據關鍵詞查詢包名

Python 如何根據關鍵詞查詢包名

參考資料:http://blog.csdn.net/xia7139/article/details/9113433

相信用過python的同學都碰到過利用pip install的時候 發現安裝程式找不到該包名的安裝包,因為python包名不一定和庫名完全相同。那麼 如何根據關鍵詞查詢包名?

以安裝lxml為例:

1. 先用 apt-cache search找到軟體的準確名字
apt-cache search lxml  
結果:  
inkscape - vector-based drawing program  
python-lxml - pythonic binding for the libxml2 and libxslt libraries  
python-lxml-dbg - pythonic binding for the libxml2 and libxslt libraries (debug extension)  
python-lxml-doc - pythonic binding for the libxml2 and libxslt libraries (documentation)  
python3-lxml - pythonic binding for the libxml2 and libxslt libraries  
python3-lxml-dbg - pythonic binding for the libxml2 and libxslt libraries (debug extension)  
xml-core - XML infrastructure and XML catalog file support  
python-okasha - trivial WSGI web framework for Python  
python-pyquery - jQuery-like library for python  
tclxml - Tcl library for XML parsing  

2. 然後就可以用apt-cache python-lxml來檢視包的依賴等詳細資訊。  
apt-cache search lxml
結果:
inkscape - vector-based drawing program
python-lxml - pythonic binding for the libxml2 and libxslt libraries
python-lxml-dbg - pythonic binding for the libxml2 and libxslt libraries (debug extension)
python-lxml-doc - pythonic binding for the libxml2 and libxslt libraries (documentation)
python3-lxml - pythonic binding for the libxml2 and libxslt libraries
python3-lxml-dbg - pythonic binding for the libxml2 and libxslt libraries (debug extension)
xml-core - XML infrastructure and XML catalog file support
python-okasha - trivial WSGI web framework for Python
python-pyquery - jQuery-like library for python
tclxml - Tcl library for XML parsing


順便查了一下apt-cache的用法,貼在下面:

apt-cache是一個apt軟體包管理工具,它可查詢apt的二進位制軟體包快取檔案。通過它我們可查詢軟體包的狀態資訊。 apt-cache show package_name 顯示軟體的資訊,包括版本號,安裝狀態和包依賴關係等。 apt-cache search package_name 搜尋軟體包,可用正則表示式。 apt-cache showpkg package_name 顯示軟體包的依賴關係資訊。 apt-cache policy package_name 顯示軟體包的安裝狀態和版本資訊。 apt-cache depends package_name 顯示指定軟體包所依賴的軟體包。
apt-cache rdepends package_name顯示軟體包的反向依賴關係,即有什麼軟體包需依賴你所指定的軟體包。