安装pytorch后,导入模块时报错
import torch
import torchvision
the repository located at download.pytorch.org is not a trusted or secure host and is being ignored. If this repository is available via HTTPS we recommend you use HTTPS instead, otherwise you may silence this warning and allow it anyway with ‘–trusted-host download.pytorch.org’
解决方案:
-
去pytorch 官网 : https://pytorch.org/get-started/locally/
-
选择自己的环境,如下图
-
官网自动给出安装命令:
pip install torch==1.6.0+cu101 torchvision==0.7.0+cu101 -f http://download.pytorch.org/whl/torch_stable.html
- 在anaconda prompt中执行命令后,报错:The repository located at pypi.doubanio.com is not a trusted or secure host and is being ignored.如图
- 因此这里面很多都是http的源,如果直接使用http的话就会出错,那怎么办呢?看了上面的提示将http改为https试试
pip install torch==1.6.0+cu101 torchvision==0.7.0+cu101 -f https://download.pytorch.org/whl/torch_stable.html
问题解决!