pip command parameters notes

Article Updated: 2020-03-31

Note: If the pipcommand is not used, see: Python PIP command can not be used

First, the arguments detailed

1, the command list

command description
install Installation package
download Download Package
uninstall Uninstall package
freeze The package has been downloaded by a specified output format
list Listed already installed package
show Displays information about installed packages
check Check the installed package exists dependent on compatibility issues
config Local or global configuration management
search In PyPIthe search package
wheel Packaged according to your requirementswheel
hash hash calculation package
completion A helper command used for command completion.
debug Output debugging information
help Displays command help information

2, common parameter list

Short format Long format description
-h --help Displays help information
--isolated Use standalone mode pip, ignoring environmental variables and user configuration
-v --verbose Show more detail. Additional options
-V --version Output version information
-q --quiet Show less detail. Additional options
--log <path> Path to a verbose appending log.
--proxy <proxy> Press the [user:passwd@]proxy.server:portformat specifies a proxy
--rettries <retries> Try the maximum number of connections, default 5
--timeout <sec> socket timeout, default 15 seconds
--exists-action <action> When the path is already present in how to deal (s)witchwith: (i)gnore, (w)ipe, (b)ackup, ,(a)bort
--trusted-host <hostname> Trusted host, even if it does not use an encrypted transmission
--cert <path> CA certification path
--client-cert <path> PEM format SSL client certificate path, that is contain a private key and certificate of
--cache-dir <dir> Cache save path
--no-cache-dir Disable Caching
--disable-pip-version-check From time to time to check whether a new version is available PyPI Implied with --no-index.
--no-color Without color display

Second, the practical application

1, commonly used commands

# pip 升级命令
python -m pip install --upgrade pip

# pip 帮助命令
pip -h
pip <command> -h
pip help <command>

2, pip installthe installation package

Short format Long format description
-r --requirement <file> Installation package from the specified file
-c --constraint <file> Specified version
--no-deps Not install dependencies
--pre Includes a preview version or development version, stable version uses only default
-e --editable <path/url> Install a project in editable mode (i.e. setuptools “develop mode”) from a local project path or a VCS url.
-t --target <dir> 指定安装目录,不会覆盖。使用--upgrade 会覆盖。
--platform <platform> 指定适用 <platform>平台的包,默认当前系统平台
--python-version <python_version> 检查包是否与指定的 python 版本兼容(3 代表 3.0.03.7 代表 3.7.0,或指定 3.7.3,如果是大版本指定 37 也可以代表 3.7
--implementation <implementation> Only use wheels compatible with Python implementation , e.g. ‘pp’, ‘jy’, ‘cp’, or ‘ip’. If not specified, then the current interpreter implementation is used. Use ‘py’ to force implementation-agnostic wheels.
--abi <abi> Only use wheels compatible with Python abi , e.g. ‘pypy_41’. If not specified, then the current interpreter abi tag is used. Generally you will need to specify --implementation, --platform, and --python-version when using this option.
--root <dir> Install everything relative to this alternate root directory.
--prefix <dir> Installation prefix where lib, bin and other top-level folders are placed
--src <dir> Directory to check out editable projects into. The default in a virtualenv is “/src”. The default for global installs is “/src”.
-U --upgrade 升级所有指定的包到最新版本
--upgrade-strategy <upgrade_strategy> Determines how dependency upgrading should be handled [default: only-if-needed]. “eager” - dependencies are upgraded regardless of whether the currently installed version satisfies the requirements of the upgraded package(s). “only-if-needed” - are upgraded only when they do not satisfy the requirements of the upgraded package(s).
--force-reinstall Reinstall all packages even if they are already up-to-date.
-I, --ignore-installed Ignore the installed packages (reinstalling instead).
--ignore-requires-python Ignore the Requires-Python information.
...
# 使用示例
pip install <package_name>

3、pip uninstall 卸载包

短格式 长格式 描述
-r --requirement 卸载所有指定的包
-y --yes 无需确认

4、pip list 列出包

短格式 长格式 描述
-o --outdated 列出过期的包
-u --uptodate 列出已更新完成的包
-e --editable 列出可编辑的项目
-l --local 如果在虚拟环境中,不列出全局包
--user 仅列出当前用户的目录下的包
--path <path> 列出指定位置的包,可指定多个位置
--pre 预览版、开发版包也列出
--format <list_format> 指定列出的格式:columns(默认)、freezejson

5、pip show列出包信息

# 列出和包相关的文件
pip show <package_name> -f
pip show <package_name> --files

6、pip search搜寻包

# 搜索要找的包
pip search <package_name>

# 指定搜索的URL
pip search <package_name> -i <url>
pip search <package_name> --index <url>

7、pip wheel

待补充

8、pip hash计算文件hash

可计算sha256sha384sha512中的一种

# 计算文件hash
pip hash -a sha256 readme.txt
pip hash --algorithm sha256 readme.txt

三、Enjoy!

发布了75 篇原创文章 · 获赞 8 · 访问量 1万+

Guess you like

Origin blog.csdn.net/qq_21516633/article/details/105223110