1.在使用pip命令时最后一行出现警告:WARNING: There was an error checking the latest version of pip.

升级pip。
# 第一种
python -m pip install --upgrade pip
# 第二种
pip install --upgrade pip
# 第三种
python -m pip install -U --force-reinstall pi

2.python使用pip导出和删除所有包的命令方法

pip freeze > requirements.txt #导出所有包
pip uninstall -r requirements.txt -y #删除所有包
  1. 报错:WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by ‘SSLError(SSLEOFError(8, ‘EOF occurred in violation of protocol (_ssl.c:749)’),)’: /pypi/simple/dataclasses/
    WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by ‘SSLError(SSLEOFError(8, ‘EOF occurred in violation of protocol (_ssl.c:749)’),)’: /pypi/simple/dataclasses/
    WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by ‘SSLError(SSLEOFError(8, ‘EOF occurred in violation of protocol (_ssl.c:749)’),)’: /pypi/simple/dataclasses/
    WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by ‘SSLError(SSLEOFError(8, ‘EOF occurred in violation of protocol (_ssl.c:749)’),)’: /pypi/simple/dataclasses/
    WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by ‘SSLError(SSLEOFError(8, ‘EOF occurred in violation of protocol (_ssl.c:749)’),)’: /pypi/simple/dataclasses/
    Could not fetch URL https://mirrors.aliyun.com/pypi/simple/dataclasses/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host=‘mirrors.aliyun.com’, port=443): Max retries exceeded with url: /pypi/simple/dataclasses/ (Caused by SSLError(SSLEOFError(8, ‘EOF occurred in violation of protocol (_ssl.c:749)’),)) - skipping
    ERROR: Could not find a version that satisfies the requirement dataclasses; python_version < “3.7” (from torch) (from versions: none)
    ERROR: No matching distribution found for dataclasses; python_version < “3.7”
原因:

***
亲测有效:
> (1)关闭翻Q的VPN,retry XXX的警告就会消失。

***
未用到:2) 下载的Torch版本,要和你的Python版本对应。

比如我电脑是Python3.6.2,PyTorch-3.6版本要求必须是Python3.6.0,于是就报了一个新错误:
ERROR: Package 'torch' requires a different Python: 3.6.0 not in '>=3.6.2'


先要关闭SSL
conda config --set ssl_verify no
然后更新python版本
conda install python=3.6.0

4.在anaconda里安装Python指令:

1。 conda create -n pytorch python=3.6

2。输入

conda activate pytorch

进入pytorch环境
在这里插入图片描述
3。输入pip list 查看已经安装的包
4。在官网下载pytorch
5。安装完后输入:

python
import torch
torch.cuda.is_available()
在这里插入图片描述如果显示ture说明已经安装成功了

更多推荐