linux常用的一些命令筆記___pip3
[root@localhost ~]# pip3 --help
Usage:
pip3 <command> [options]
Commands:
install Install packages.
download Download packages.
uninstall Uninstall packages.
freeze Output installed packages in requirements format.
list List installed packages.
show Show information about installed packages.
check Verify installed packages have compatible dependencies.
config Manage local and global configuration.
search Search PyPI for packages.
wheel Build wheels from your requirements.
hash Compute hashes of package archives.
completion A helper command used for command completion.
debug Show information useful for debugging.
help Show help for commands.
General Options:
-h, --help Show help.
--isolated Run pip in an isolated mode, ignoring environment variables and user configuration.
-v, --verbose Give more output. Option is additive, and can be used up to 3 times.
-V, --version Show version and exit.
-q, --quiet Give less output. Option is additive, and can be used up to 3 times (corresponding to WARNING, ERROR, and CRITICAL logging levels).
--log <path> Path to a verbose appending log.
--proxy <proxy> Specify a proxy in the form [user:passwd@]proxy.server:port.
--retries <retries> Maximum number of retries each connection should attempt (default 5 times).
--timeout <sec> Set the socket timeout (default 15 seconds).
--exists-action <action> Default action when a path already exists: (s)witch, (i)gnore, (w)ipe, (b)ackup, (a)bort.
--trusted-host <hostname> Mark this host as trusted, even though it does not have valid or any HTTPS.
--cert <path> Path to alternate CA bundle.
--client-cert <path> Path to SSL client certificate, a single file containing the private key and the certificate in PEM format.
--cache-dir <dir> Store the cache data in <dir>.
--no-cache-dir Disable the cache.
--disable-pip-version-check
Don't periodically check PyPI to determine whether a new version of pip is available for download. Implied with --no-index.
--no-color Suppress colored output
安裝 & 移除
-
安裝指定包的最新版
pip3 install pkg_name -
安裝制定包的指定版本
pip3 install pkg_name==version -
移除指定包
pip3 uninstall pkg_name -
在 PyPI 上模糊查找相關包
pip3 search pkg_name
查看相關
-
pip install/downloadinstall是聯網安裝,而download是本地離線下載
pip download pkg_name -d download_path -
查看已經安裝的包
pip3 list[root@localhost ~] pip3 list Package Version ------------------ --------- aiohttp 3.7.4 amqp 5.0.5 async-timeout 3.0.1 attrs 20.3.0 -
查看指定包的相關資訊
pip3 show pkg_name[root@localhost ~] pip3 show zipp Name: zipp Version: 3.4.0 Summary: Backport of pathlib-compatible object wrapper for zip files Home-page: https://github.com/jaraco/zipp Author: Jason R. Coombs Author-email: [email protected] License: UNKNOWN Location: /usr/local/python3/lib/python3.8/site-packages Requires: Required-by: importlib-metadata, ratelRequires 和 Required-by 兩個屬性分別表示 zip 要依賴和被依賴的包情況;zipp 不需要任何依賴,而 zipp 被importlib-metadata和ratel依賴,所以洗掉之后會影響這兩個的使用,最好對request 所有的依賴依次使用 pip show 運行一下查看具體依賴情況,
-
輸出所有在本地已安裝的包
pip3 freeze: 使用pip freeze會輸出所有在本地已安裝的包(但不包括pip、wheel、setuptools等自帶包),若需要輸出內容與pip list一致,需使用pip freeze -all,[root@localhost ~] pip3 freeze all aiohttp==3.7.4 amqp==5.0.5 async-timeout==3.0.1 attrs==20.3.0 Automat==20.2.0 beautifulsoup4==4.9.3pip3 freeze > requirements.txt: 當我們開發專案的時候會出現在不同環境下安裝相同的模塊的時為了避免我們通過聯網下載所需模塊,我們直接從之前python環境已經有的模塊中直接拿來用,所以一般這個命令需要虛擬環境來維護當前的包版本,防止不同專案的不同版本包放在一起會造成混亂

-
修改pip組態檔
pip3 config國內源
清華:https://pypi.tuna.tsinghua.edu.cn/simple 阿里云:http://mirrors.aliyun.com/pypi/simple/ 中國科技大學 https://pypi.mirrors.ustc.edu.cn/simple/ 華中理工大學:http://pypi.hustunique.com/ 山東理工大學:http://pypi.sdutlinux.org/ 豆瓣:http://pypi.douban.com/simple/-
pip config set
這個命令允許我們以name=value的形式配置某些項,比如設定鏡像源:
pip config set global.index-url https://mirrors.cloud.tencent.com/pypi/simple -
pip config get
這個命令允許我們查看某個配置項的值,比如查看鏡像源配置:
pip config get global.index-url -
pip config edit
這個命令允許我們用一個編輯器打開組態檔進行編輯,如果我們沒有指定--editor選項,就會用VISUAL或者EDITOR環境變數的值作為編輯器,如下命令:
pip config --editor=vi edit -
pip config list
這個命令以name=value的形式輸出當前配置,假如我們已經執行了上面的pip config set命令,這時再執行 pip config list就會輸出如下:
global.index-url='https://mirrors.cloud.tencent.com/pypi/simple' -
pip3 config debug
這個命令列出各個組態檔位置及其內容
-
pip3 config unset
-
-
檢查需要的包的缺失匹配情況
pip3 check[root@localhost ~]# pip3 check paramiko 2.10.3 requires bcrypt, which is not installed. paramiko 2.10.3 requires cryptography, which is not installed. pynacl 1.5.0 requires cffi, which is not installed. -
pip3 --disable-pip-version-check install --no-index --find-links=第一個引數 --disable-pip-version-check 后面跟著的注釋大意為:不要定期檢查PyPI以確定是否有新版本的pip可供下載,暗示和--no-index聯用
意思就是一般在斷網情況下的離線安裝,都是直接從其他主機安裝資源包,所以要取消更新
其中 --no-index 代表忽視pip 忽視默認的依賴包索引,--find-links= 代表從你指定的目錄尋下找離線包
-
pip download --platform anylinux_x86_64 --no-deps on -d pip_packages/ -r project/requirements.txt其中:--platform 指定平臺資訊, --no-deps:on 代表不安裝依賴項,-d 后面指定依賴包下載目錄,最后跟上requirement.txt,
本文來自博客園,作者:ivanlee717,轉載請注明原文鏈接:https://www.cnblogs.com/ivanlee717/p/16265856.html
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/473419.html
標籤:Python
上一篇:python常用內置函式和關鍵字
