[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
站在用戶的角度思考問題,與客戶深入溝通,找到尚義網(wǎng)站設(shè)計與尚義網(wǎng)站推廣的解決方案,憑借多年的經(jīng)驗,讓設(shè)計與互聯(lián)網(wǎng)技術(shù)結(jié)合,創(chuàng)造個性化、用戶體驗好的作品,建站類型包括:成都做網(wǎng)站、網(wǎng)站制作、成都外貿(mào)網(wǎng)站建設(shè)、企業(yè)官網(wǎng)、英文網(wǎng)站、手機端網(wǎng)站、網(wǎng)站推廣、域名與空間、雅安服務(wù)器托管、企業(yè)郵箱。業(yè)務(wù)覆蓋尚義地區(qū)。
安裝制定包的指定版本
pip3 install pkg_name==version
移除指定包
pip3 uninstall pkg_name
在 PyPI 上模糊查找相關(guān)包
pip3 search pkg_name
pip install/download
install是聯(lián)網(wǎng)安裝,而download是本地離線下載
pip download pkg_name -d download_path
查看已經(jīng)安裝的包
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: jaraco@jaraco.com
License: UNKNOWN
Location: /usr/local/python3/lib/python3.8/site-packages
Requires:
Required-by: importlib-metadata, ratel
Requires 和 Required-by 兩個屬性分別表示 zip 要依賴和被依賴的包情況;zipp 不需要任何依賴,而 zipp 被importlib-metadata和ratel依賴,所以刪除之后會影響這兩個的使用,最好對request 所有的依賴依次使用 pip show 運行一下查看具體依賴情況。
輸出所有在本地已安裝的包
pip3 freeze
: 使用 pip freeze
會輸出所有在本地已安裝的包(但不包括 pip
、wheel
、setuptools
等自帶包),若需要輸出內(nèi)容與 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.3
pip3 freeze > requirements.txt
: 當(dāng)我們開發(fā)項目的時候會出現(xiàn)在不同環(huán)境下安裝相同的模塊的時為了避免我們通過聯(lián)網(wǎng)下載所需模塊,我們直接從之前python環(huán)境已經(jīng)有的模塊中直接拿來用。
所以一般這個命令需要虛擬環(huán)境來維護(hù)當(dāng)前的包版本,防止不同項目的不同版本包放在一起會造成混亂
修改pip配置文件
pip3 config
國內(nèi)源
清華:https://pypi.tuna.tsinghua.edu.cn/simple
阿里云:http://mirrors.aliyun.com/pypi/simple/
中國科技大學(xué) https://pypi.mirrors.ustc.edu.cn/simple/
華中理工大學(xué):http://pypi.hustunique.com/
山東理工大學(xué):http://pypi.sdutlinux.org/
豆瓣:http://pypi.douban.com/simple/
pip config set
這個命令允許我們以name=value的形式配置某些項,比如設(shè)置鏡像源:
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
這個命令允許我們用一個編輯器打開配置文件進(jìn)行編輯,如果我們沒有指定--editor選項,就會用VISUAL或者EDITOR環(huán)境變量的值作為編輯器,如下命令:
pip config --editor=vi edit
pip config list
這個命令以name=value的形式輸出當(dāng)前配置,假如我們已經(jīng)執(zhí)行了上面的pip config set命令,這時再執(zhí)行 pip config list就會輸出如下:
global.index-url='https://mirrors.cloud.tencent.com/pypi/simple'
pip3 config debug
這個命令列出各個配置文件位置及其內(nèi)容
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=
第一個參數(shù) --disable-pip-version-check 后面跟著的注釋大意為:不要定期檢查PyPI以確定是否有新版本的pip可供下載。暗示和--no-index聯(lián)用
意思就是一般在斷網(wǎng)情況下的離線安裝,都是直接從其他主機安裝資源包,所以要取消更新
其中 --no-index 代表忽視pip 忽視默認(rèn)的依賴包索引。--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。
文章名稱:pip常見命令
當(dāng)前鏈接:http://chinadenli.net/article6/dsogpog.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供自適應(yīng)網(wǎng)站、品牌網(wǎng)站建設(shè)、網(wǎng)站制作、微信公眾號、電子商務(wù)、品牌網(wǎng)站制作
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)