ModuleNotFoundError: No module named 'graphgym'
时间: 2023-08-15 07:15:27 浏览: 264
引用\[1\]: File "d:\Programfile\graphgym\run\main_pyg.py", line 10, in <module> from graphgym.loader_pyg import create_dataset, create_loader File "D:\Programfile\graphgym\gymenv\lib\site-packages\graphgym\loader_pyg.py", line 23, in <module> from torch_geometric.data.graph_saint import (GraphSAINTNodeSampler, ModuleNotFoundError: No module named 'torch_geometric.data.graph_saint' 。 引用\[2\]:1 不能简单的直接pip install torch_geometric或者 conda install torch_geometric 2 直接安装,到后面调用的时候还是会报错.需要先安装四个小部件再安装torch_geometric 。 引用\[3\]:注意到,其实在环境里,是可以用grep在D:\Programfile\graphgym\gymenv\lib\site-packages\torch_geometric\data目录下找到【GraphSAINTNodeSampler】的。因此,直接更改loader_pyg.py,将以下代码更改为: from torch_geometric.data.graph_saint import (GraphSAINTNodeSampler, GraphSAINTEdgeSampler, GraphSAINTRandomWalkSampler) from torch_geometric.data.cluster import ClusterLoader from torch_geometric.data.sampler import RandomNodeSampler, NeighborSampler ---------------------------------------------------------------------------------------- from torch_geometric.data import (GraphSAINTNodeSampler, GraphSAINTEdgeSampler, GraphSAINTRandomWalkSampler) from torch_geometric.data import ClusterLoader from torch_geometric.data import RandomNodeSampler, NeighborSampler 。 问题:ModuleNotFoundError: No module named 'graphgym'
回答: 根据引用\[1\]的错误信息,出现了ModuleNotFoundError: No module named 'torch_geometric.data.graph_saint'的错误。根据引用\[2\]的建议,直接安装torch_geometric可能会导致后续调用时仍然报错。需要先安装四个小部件再安装torch_geometric。此外,根据引用\[3\]的提示,可以在D:\Programfile\graphgym\gymenv\lib\site-packages\torch_geometric\data目录下找到GraphSAINTNodeSampler。因此,可以尝试更改loader_pyg.py文件中的代码,将from torch_geometric.data.graph_saint import (GraphSAINTNodeSampler, GraphSAINTEdgeSampler, GraphSAINTRandomWalkSampler)这一行改为from torch_geometric.data import (GraphSAINTNodeSampler, GraphSAINTEdgeSampler, GraphSAINTRandomWalkSampler)。这样可能可以解决ModuleNotFoundError的问题。
#### 引用[.reference_title]
- *1* *3* [pyg与graphgym](https://blog.csdn.net/guanjian6334/article/details/123657676)[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^v91^control,239^v3^insert_chatgpt"}} ] [.reference_item]
- *2* [ModuleNotFoundError: No module named ‘torch_geometric](https://blog.csdn.net/m13526413031/article/details/121602700)[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^v91^control,239^v3^insert_chatgpt"}} ] [.reference_item]
[ .reference_list ]
阅读全文