在Python 3.9.7中导入torch_geometric时出错



我试图在conda环境中安装torch_geometric,但每当我尝试时,我都会得到以下错误:

import torch_geometric

错误:

OSError: dlopen(/Users/psanchez/miniconda3/envs/playbook/lib/python3.9/site-packages/libpyg.so, 0x0006): Library not loaded: /usr/local/opt/python@3.10/Frameworks/Python.framework/Versions/3.10/Python
Referenced from: <95F9BBA5-21FB-3EA5-9028-172B745E6ABA> /Users/psanchez/miniconda3/envs/playbook/lib/python3.9/site-packages/libpyg.so
Reason: tried: '/usr/local/opt/python@3.10/Frameworks/Python.framework/Versions/3.10/Python' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/usr/local/opt/python@3.10/Frameworks/Python.framework/Versions/3.10/Python' (no such file), '/usr/local/opt/python@3.10/Frameworks/Python.framework/Versions/3.10/Python' (no such file), '/Library/Frameworks/Python.framework/Versions/3.10/Python' (no such file), '/System/Library/Frameworks/Python.framework/Versions/3.10/Python' (no such file, not in dyld cache)

我是这样安装conda环境的:

onda create --name playbook python=3.9.7  --no-default-packages
conda activate playbook
pip install torch==1.13.1 torchvision==0.14.1

pip install pyg-lib torch-scatter torch-sparse torch-cluster torch-spline-conv torch-geometric -f https://data.pyg.org/whl/torch-1.13.0+cpu.html

你知道怎么解决这个错误吗?

提前感谢!

我也遇到过这个问题——我不知道为什么需要Python 3.10。但是我能够通过安装全局版本Python 3.10来解决这个问题:

https://www.python.org/downloads/macos/

这允许它在你的虚拟环境之外访问Python 3.10。

如果检查错误信息,请在"引用自"你可以看到Python的3.9版本,但是在"Reason tried"这一行,你看到的是Python的3.10版本。

所以我认为你正在使用Python环境3.10与Python 3.9或相反。您应该干净地重新创建您的环境。

我也有这个问题。我使用python3.7,它工作:

conda create -n pygeometric python=3.7
conda activate pygeometric
conda install pytorch torchvision -c pytorch
python -c "import torch; print(torch.__version__)"
conda install -y clang_osx-64 clangxx_osx-64 gfortran_osx-64
MACOSX_DEPLOYMENT_TARGET=10.9 CC=clang CXX=clang++
pip install torch_scatter
python -c "import torch_scatter; print(torch_scatter.__version__)"
pip install torch_sparse 
python -c "import torch_sparse; print(torch_sparse.__version__)"
pip install torch_cluster
python -c "import torch_cluster; print(torch_cluster.__version__)"
pip install torch-spline-conv
python -c "import torch_spline_conv;print(torch_spline_conv.__version__)"
pip install torch_geometric
python -c "import torch_geometric;print(torch_geometric.__version__)"

最新更新