示例一:两种写法等价
pip install 库名 -i https://pypi.douban.com/simple/
示例二:
此参数“--trusted-host”表示信任,如果上一个提示不受信任,就先使用这个添加网址信任
pip install -i https://pypi.douban.com/simple/--trusted-host pypi.douban.com
pip install -i https://pypi.douban.com/simple/ 库名
1.清华:https://pypi.tuna.tsinghua.edu.cn/simple
3.豆瓣:https://pypi.douban.com/simple/
4.中国科技大学:https://pypi.mirrors.ustc.edu.cn/simple/
如果pip版本>=10.0.0,可以使用如下命令进行设置:
pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/
此参数“global.trusted-host”表示信任网址,如果上一个提示不受信任,就使用这个
pip config set global.trusted-host mirrors.aliyun.compip config set global.index-url https://mirrors.aliyun.com/pypi/simple/
在Linux下, 修改 ~/.pip/pip.conf (没有就创建一个文件夹及文件。文件夹要加“.”,表示是隐藏文件夹) 内容如下:
[global]
index-url = https://mirrors.aliyun.com/pypi/simple/
[install]
trusted-host=mirrors.aliyun.com
windows下,直接在user目录中创建一个pip目录,再新建文件pip.ini。(例如:C:\Users\999\pip\pip.ini)内容同上。
第一步:下载 pack_name.whl到本地文件夹
第二步:在控制台 cd进入到下载好的 torch目录
第三步:使用 pip install pack_name.whl进行安装
Python有海量的第三方库或者说模块,这些库针对不同的应用,发挥不同的作用。
Python官方的PyPi仓库为我们提供了一个统一的代码托管仓库,所有的第三方库,甚至你自己写的开源模块,都可以发布到这里,让全世界的人分享下载。
pip 是 Python中的标准库管理器。它允许你安装和管理不属于 Python标准库 的其它软件包。pip提供了对 Python 包的查找、下载、安装、卸载等功能。
目前如果你在 python.org 下载最新版本的安装包,则是已经自带了该工具。
注意:Python 2.7.9 + 或 Python 3.4+ 以上版本都自带 pip 工具。
?pip 官网:https://pypi.org/project/pip/
pip --version #Python2.x 版本命令
pip3 --version #Python3.x 版本命令
pip -V
pip
where pip
pip --help
ubuntu下:
sudo apt-get install python-pip
Fedora系下:
sudo yum install python-pip
win系统在线安装:
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.pypython get-pip.py
win系统本地安装:?在官网下载 pip安装包 https://pypi.org/project/pip/#downloads
1.下载完成后,将得到一个压缩包,将压缩包进行解压。
2.打开控制台,使用cd命令进入解压后的文件夹至可执行目录
3.执行命令:
python setup.py install
pip listpip list --outdated #可以查看有新版本的第三方库,可显示现在安装的版本,以及最新的版本
pip list -o
pip install 库名
pip install 库名==版本号 #安装指定版本
pip install 库名 -i https://pypi.douban.com/simple/
pip search SomePackage
pip show 库名 pip show -f 库名
pip freeze > requirements.txt
pip install -r requirements.txt
pip install --upgrade SomePackage
pip uninstall 库名
Linux 或 macOS:
pip install --upgrade pip
win系统:
python -m pip install -U pip
python -m pip uninstall pip#也可以直接把pip文件夹删了;
建议使用命令后把遗留的文件删除即可。
用法:
pip <命令> [选项]
命令:
install --安装软件包。
download --下载软件包。
uninstall --卸载软件包。
freeze --以需求格式输出已安装的软件包目录。
list --列出已安装的软件包。
show --显示有关已安装软件包的信息。
check --验证已安装的软件包是否具有兼容的依赖项。
config --管理本地和全局配置。
search --在PyPI中搜索包。
cache --检查和管理pip的 wheel文件缓存。
index --检查包索引中的可用信息。
wheel --根据您的要求制造 wheel文件。
hash --计算包档案的散列值。
completion --用于命令完成的辅助命令。
debug --显示调试过程中有用的信息。
help --显示命令的帮助信息。
常用选项:
-h, --help --显示帮助信息。
--debug --允许未处理的异常在主子程序之外发生,而不是将它们记录到标准错误。
--isolated --以隔离模式运行pip,忽略环境变量和用户配置。
--require-virtualenv --允许pip仅在虚拟环境中运行;否则退出时出错。
-v, --verbose --增加输出。该选项为可选项,最多可使用3次。
-V, --version --显示版本并退出。
-q, --quiet --减少输出。该选项是可选项,最多可使用3次(对应于警告、错误和关键日志记录级别)。
--log <path> --附加日志的详细路径。
--no-input --禁用输入提示。
--proxy <proxy> --以[user:passwd@]proxy.server:port.的形式指定代理服务器端口。
--retries <retries> --每个连接应尝试的最大重试次数(默认为5次)。
--timeout <sec> --设置套接字超时(默认为15秒)。
--exists-action <action> --当路径已经存在时的默认操作:(s)witch,(i)gnore,(w)ipe,(b)ackup,
--trusted-host <hostname> --将此主机或主机:端口标记为受信任,即使它不安全或不是HTTPS。
--cert <path> --PEM编码的CA证书的路径。如果提供,将覆盖默认值。请参阅“SSL”有关更多信息,请参阅pip文档中的“证书验证”。
--client-cert <path> --SSL客户端证书的路径,一个包含私钥和PEM格式的证书。
--cache-dir <dir> --将缓存数据存储在<dir路径>中。
--no-cache-dir --禁用缓存。
--disable-pip-version-check --不定期检查PyPI是否有新版本的pip可供用户使用下载,隐含着——没有索引。
--no-color --抑制彩色输出。
--no-python-version-warning --对未来不受支持的Python版本不发出警告。
--use-feature <feature> --启用可能向后不兼容的新功能。
--use-deprecated <feature> --启用不推荐使用的功能,这些功能将在将来删除。
原文:
Usage:
pip <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.
cache Inspect and manage pip's wheel cache.
index Inspect information available from package indexes.
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.
--debug Let unhandled exceptions propagate outside the main subroutine, instead of logging them
to stderr.
--isolated Run pip in an isolated mode, ignoring environment variables and user configuration.
--require-virtualenv Allow pip to only run in a virtual environment; exit with an error otherwise.
-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.
--no-input Disable prompting for input.
--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 or host:port pair as trusted, even though it does not have valid or any
HTTPS.
--cert <path> Path to PEM-encoded CA certificate bundle. If provided, overrides the default. See 'SSL
Certificate Verification' in pip documentation for more information.
--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.
--no-python-version-warning
Silence deprecation warnings for upcoming unsupported Pythons.
--use-feature <feature> Enable new functionality, that may be backward incompatible.
--use-deprecated <feature> Enable deprecated functionality, that will be removed in the future.