import无法定位到输入点

torch-geometric安装

运行环境需要torch-geometric,下载安装完之后,再 import torch-geometric时,一直出错,安装不上,找了很多解决方法,终于找到可以解决的办法了,亲测有效
原因:最终发现因为新安装的torch-sparse、torch_scatter、 torch_cluster及torch-geometric与pytorch版本不匹配
注意:torch-geometric安装前,需要先安装torch-sparse、torch_cluster 和 torch_scatter。

1、卸载

先卸载错误版本的torch-sparse、torch_scatter、 torch_cluster及torch-geometric,下载了什么就卸载什么,用如下卸载命令

pip uninstall torch-scatter torch-sparse torch-cluster torch-geometric

2、安装

注意:需要根据自己的环境来下载对应的版本,一定要看仔细了,这里以我的pytorch版本torch-1.11.0(CPU)为例:

wget https://data.pyg.org/whl/torch-1.11.0%2Bcpu/torch_scatter-2.0.9-cp37-cp37m-win_amd64.whl
pip install torch_scatter-2.0.9-cp37-cp37m-win_amd64.whl
wget https://data.pyg.org/whl/torch-1.11.0%2Bcpu/torch_sparse-0.6.13-cp37-cp37m-win_amd64.whl
pip install torch_sparse-0.6.13-cp37-cp37m-win_amd64.whll
wget https://data.pyg.org/whl/torch-1.11.0%2Bcpu/torch_cluster-1.5.6%2Bcpu-cp37-cp37m-win_amd64.whl
pip install torch_cluster-1.5.6+cpu-cp37-cp37m-win_amd64.whl
wget https://data.pyg.org/whl/torch-1.11.0%2Bcpu/torch_spline_conv-1.2.1-cp37-cp37m-win_amd64.whl
pip install torch_spline_conv-1.2.1-cp37-cp37m-win_amd64.whl
pip install torch-geometric

下载whl文件,参考官方网址

3、验证安装成功

import torch
import torch_geometric

没报错表明安装成功:
在这里插入图片描述

你可能感兴趣的:(笔记,深度学习,pytorch,人工智能)