项目场景:
conda虚拟环境下安装pytorch_geometric库
安装命令如下:
conda install pyg -c pyg -c conda-forge
问题描述
安装报错:UnsatisfiableError: The following specifications were found to be incompatible with each other: Output in format: Requested package -> Available versions
原因分析:
pytorch 的版本问题,报错环境是2.0.1的版本
解决方案:
删除环境,新建环境,新环境安装1.8.0的pytorch
在官网找到安装旧版本pytorch使用的代码:
链接: https://pytorch.org/get-started/previous-versions/
安装1.8.0版本的代码如下:
conda install pytorch==1.8.0 torchvision==0.9.0 torchaudio==0.8.0 cudatoolkit=11.1 -c pytorch -c conda-forge
安装还是报错:
Specifications:
- pytorch==1.8.0 -> python[version='>=3.6,<3.7.0a0|>=3.9,<3.10.0a0|>=3.7,<3.8.0a0|>=3.8,<3.9.0a0']
- torchaudio==0.8.0 -> python[version='>=3.6,<3.7.0a0|>=3.8,<3.9.0a0|>=3.9,<3.10.0a0|>=3.7,<3.8.0a0']
- torchvision==0.9.0 -> python[version='>=3.6,<3.7.0a0|>=3.7,<3.8.0a0|>=3.8,<3.9.0a0|>=3.9,<3.10.0a0']
Your python: python=3.11
原因
环境的python版本为3.11,和我要安装的pytorch1.8.0版本不兼容
解决方案
删除环境,新建python版本为3.8的环境,再安装pytorch
代码如下:
conda remove -n pyg --all
conda create -n pyg python==3.8
activate pyg
conda install pytorch==1.8.0 torchvision==0.9.0 torchaudio==0.8.0 cudatoolkit=11.1 -c pytorch -c conda-forge
安装好pytorch1.8.0后再安装geometric
命令如下:
conda install pyg -c pyg -c conda-forge
安装之后在命令行输入
python
import torch_geometric
没有报错,即表示安装成功。