一.pip
1.为什么要用pip?
pip 是 Python 包管理工具,该工具提供了对Python 包的查找、下载、安装、卸载的功能。可以用命令行直接实行对包的管理,非常方便。
2.pip的下载?
目前如果你在 python.org 下载最新版本的安装包,则是已经自带了该工具。
Python 2.7.9 + 或 Python 3.4+ 以上版本都自带 pip 工具。
或者可以在https://pypi.org/project/pip/中直接安装。
可以通过如下命令查看是否安装成功
pip --version
或
pip -V
pip更新到最新版本
pip install -U pip
3.带你看pip的帮助文档
输入 pip --help
Usage:
pip [options]
Commands:
1.安装包
install Install packages.
pip install SomePackage # 最新版本
pip install SomePackage==1.0.4 # 指定版本
pip install 'SomePackage>=1.0.4' # 最小版本
比如我要安装 Django。用以下的一条命令就可以,方便快捷。
pip install Django==1.7
(升级包)
pip install --upgrade SomePackage
或
pip install -U SomePackage
比如更新numpy
download
Download packages.
uninstall
Uninstall packages.
freeze
Output installed packages in requirements format.
列出已安装的包。
list
List installed packages.
显示有关已安装包的信息
show Show information about installed packages.
pip show numpy
Name: numpy
Version: 1.19.0
Summary: NumPy is the fundamental package for array computing with Python.(概要: NumPy 是用 Python 进行数组计算的基本包。)
Home-page: https://www.numpy.org(主页)
(作者)Author: Travis E. Oliphant et al.
Author-email: None
License: BSD
(位置)Location: c:\users\administrator\appdata\local\programs\python\python37\lib\site-packages
Requires:
(必须项)Required-by: matplotlib
check
Verify installed packages have compatible
dependencies.验证已安装的包是否具有兼容的依赖关系。
config
Manage local and global configuration.管理本地和全局配置。
search
Search PyPI for packages.
cache
Inspect and manage pip’s wheel cache.
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
–proxy Specify a proxy in the form [user:passwd@]proxy.server:port.
–retries Maximum number of retries each connection should attempt (default 5 times).
–timeout Set the socket timeout (default 15 seconds).
–exists-action Default action when a path already exists: (s)witch, (i)gnore, (w)ipe, (b)ackup,
(a)bort.
–trusted-host Mark this host or host:port pair as trusted, even though it does not have valid or any
HTTPS.
–cert
–client-cert
certificate in PEM format.
–cache-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
–no-python-version-warning
Silence deprecation warnings for upcoming unsupported Pythons.