python如何安装torch_Python安装torch模块报错处理

Python安装torch模块报错处理前言安装报错解决查找文档解决方案安装 torch等待安装完成安装 torchvision提示安装完成总结前言因python项目上线,需要在海外服务器上安装指定torch模块安装根据官网https://pytorch.org/安装提示,执行pip3 install即可。pip3 install torch torchvision但安装过程中发生报错,尝试多次执行...
摘要由CSDN通过智能技术生成

Python安装torch模块报错处理

前言

安装

报错

解决

查找文档

解决方案

安装 torch

等待安装完成

安装 torchvision

提示安装完成

总结

前言

因python项目上线,需要在海外服务器上安装指定torch模块

安装

根据官网https://pytorch.org/安装提示,执行pip3 install即可。

pip3 install torch torchvision

但安装过程中发生报错,尝试多次执行pip3 install torch torchvision,仍会重置下载。

报错

$ pip3 install torch

WARNING: pip is being invoked by an old script wrapper. This will fail in a future version of pip.

Please see https://github.com/pypa/pip/issues/5599 for advice on fixing the underlying issue.

To avoid this problem you can invoke Python with '-m pip' instead of running pip directly.

Looking in indexes: http://ap-south-1.mirrors.cloud.aliyuncs.com/pypi/simple/

Collecting torch

Downloading http://ap-south-1.mirrors.cloud.aliyuncs.com/pypi/packages/62/01/457b49d790b6c4b9720e6f9dbbb617692f6ce8afdaadf425c055c41a7416/torch-1.5.1-cp36-cp36m-manylinux1_x86_64.whl (753.2 MB)

|████████▊ | 206.4 MB 48 kB/s eta 3:06:38ERROR: Exception:

Traceback (most recent call last):

File "/data/python3/lib/python3.6/site-packages/pip/_vendor/urllib3/response.py", line 425, in _error_catcher

yield

File "/data/python3/lib/python3.6/site-packages/pip/_vendor/urllib3/response.py", line 507, in read

data = self._fp.read(amt) if not fp_closed else b""

File "/data/python3/lib/python3.6/http/client.py", line 449, in read

n = self.readin

  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
在jupyter中使用import torch报错通常是由于没有正确安装torch库所致。首先,你可以检查是否在jupyter notebook中使用了正确的Python内核(比如使用了正确的虚拟环境)。如果你确定使用了正确的内核,那么这个问题可能是由于没有正确安装torch库引起的。 针对这个问题,你可以按照以下步骤进行排查和解决: 1. 确保你已经在Anaconda Prompt中以管理员身份运行,并且已经激活了你的pytorch虚拟环境。 2. 在Anaconda Prompt中运行`conda list`命令,查看已经安装的包列表,确认torch是否在其中。如果没有安装torch,你可以通过运行`conda install pytorch`或者`pip install torch`来安装。 3. 如果你已经安装torch,但是在jupyter中仍然报错,那么可能是因为jupyter内核没有正确加载你的虚拟环境。你可以尝试在jupyter notebook中重新选择正确的内核。在jupyter notebook中,点击菜单栏的Kernel -> Change Kernel,选择你的虚拟环境对应的内核。 4. 如果以上方法都没有解决问题,你可以尝试重新安装jupyter notebook。在Anaconda Prompt中运行`conda remove jupyter notebook`命令来卸载jupyter notebook,然后再运行`conda install jupyter notebook`命令来重新安装。 5. 如果问题仍然存在,你可以尝试在jupyter notebook中使用`pip install torch`来重新安装torch库。 综上所述,如果在jupyter中使用import torch报错,你可以检查是否使用了正确的Python内核以及是否正确安装torch库。如果问题仍然存在,你可以尝试重新安装jupyter notebook。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [Jupyter notebook 上无法使用argparse.parse_args()](https://download.csdn.net/download/weixin_38621624/13752668)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] - *2* *3* [解决jupyter中import torch出错问题](https://blog.csdn.net/qq_45720073/article/details/125948597)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值