第一件事当然是换源 ~
阿里云 http://mirrors.aliyun.com/pypi/simple/
中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/
豆瓣(douban) http://pypi.douban.com/simple/
清华大学 https://pypi.tuna.tsinghua.edu.cn/simple/
中国科学技术大学 http://pypi.mirrors.ustc.edu.cn/simple/
临时使用:
可以在使用pip的时候在后面加上-i参数,指定pip源
eg: pip install scrapy -i https://pypi.tuna.tsinghua.edu.cn/simple
永久修改:
LInux系统
修改 ~/.pip/pip.conf
(没有就创建一个), 内容如下:
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
Windows:
win+R 打开用户目录%HOMEPATH%,在此目录下创建 pip 文件夹,在 pip 目录下创建 pip.ini 文件, 内容如下:
[global]
timeout = 6000
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
trusted-host = pypi.tuna.tsinghua.edu.cn
添加清华的镜像源
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --set show_channel_urls yes
conda - -help // 找到配置文件.condarc 的路径 ,将上述显示的配置信息中 - defaults 所在行删除保存即可
查看源:
conda config --show channels
换回默认源
conda config --remove-key channels
pip3 --help
Usage:
pip [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.
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.
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 to a verbose appending 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 as trusted, even though it does not have valid or any HTTPS.
--cert Path to alternate CA bundle.
--client-cert Path to SSL client certificate, a single file containing the private key and
the certificate in PEM format.
--cache-dir Store the cache data in .
--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.
pip3 install pkg_name
pip3 install pkg_name==version
$ pip3 install django==2.0.5
pip3 uninstall pkg_name
pip3 search pkg_name
pip3 list
形如:
amqp (1.4.9)
anyjson (0.3.3)
asn1crypto (0.24.0)
pip3 show pkg_name
$ pip3 show django
Name: Django
Version: 2.1.4
Summary: A high-level Python Web framework that encourages rapid development and clean, pragmatic design.
Home-page: https://www.djangoproject.com/
Author: Django Software Foundation
Author-email: [email protected]
License: BSD
Location: /home/ezreal/.local/lib/python3.6/site-packages
Requires: pytz
在 Anaconda prompt 环境下
conda upgrade pip
普通环境
python -m pip install --upgrade pip
检查哪些包需要更新
pip list --outdated
更新指定包
pip install --upgrade pkg_name
pip3 freeze
形如:
vine==1.1.4
virtualenv==16.1.0
youtube-dl==2018.9.10
pip3 freeze > requirements.txt
# 需要安装第三方库
pip3 install pipreqs
# .表示当前目录
pipreqs . --encoding=utf8
pip3 install -r requirements.txt
pip install --user --upgrade tensorflow-gpu
[1] PIP 更换国内安装源:https://blog.csdn.net/yuzaipiaofei/article/details/80891108