我正在尝试安装:
pip install torch-scatter==2.1.1
并收到以下错误:
Collecting torch-scatter==2.1.1
Using cached torch_scatter-2.1.1.tar.gz (107 kB)
Installing build dependencies ... done
Getting requirements to build wheel ... error
error: subprocess-exited-with-error
× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> [17 lines of output]
\Local\Temp\pip-build-env-hgzk7elh\overlay\Lib\site-packages\setuptools\build_meta.py", line 311, in run_setup
exec(code, locals())
File "<string>", line 8, in <module>
ModuleNotFoundError: No module named 'torch'
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error
× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> See above for output.
torch 2.1.2 已正确安装,我可以通过
pip list
看到它。
点已更新 (23.3.2)。
setuptools 由
pip install --upgrade --force-reinstall setuptools
更新(69.0.3)。
我也尝试过:
pip install torch-scatter==2.1.1 -f https://data.pyg.org/whl/torch-2.1.2+${cpu}.html
遇到同样的错误。
我在Windows系统中的(.venv)上运行。 有人可以帮我解决问题吗?谢谢。
错误消息表明在构建
torch-scatter
轮子时,构建环境中找不到
torch
。 即使在主环境中安装了
torch
,构建环境也可能是隔离的,并且无法访问它。
可以尝试以下方法来解决此问题:
1. 为的
torch
版本指定正确的轮子:
-
访问
https://data.pyg.org/whl/torch-2.1.2+${cpu}.html
并找到与的
torch
版本 (2.1.2) 和平台(例如cp39
表示 Python 3.9)匹配的torch-scatter
轮子文件名。 -
使用
pip
直接安装该轮子:bash pip install torch_scatter-2.1.1-{your_platform}.whl
-
将
{your_platform}
替换为实际的平台字符串,例如cp39-cp39-win_amd64.whl
。
2. 在安装
torch-scatter
之前安装
torch
:
-
确保的
.venv
处于活动状态。 -
运行以下命令:
bash pip install torch==2.1.2 pip install torch-scatter==2.1.1
-
这将确保在构建
torch-scatter
之前安装torch
,并且构建环境可以访问它。
3. 使用
--no-build-isolation
标志:
-
此标志禁用构建隔离,并允许构建环境访问主环境中的包。
bash pip install --no-build-isolation torch-scatter==2.1.1
-
注意: 这可能会导致与其他包的兼容性问题,因此请谨慎使用。
如果上述方法都不起作用,请尝试以下操作:
-
升级
pip
:pip install --upgrade pip
-
清理缓存:
pip cache purge
-
删除
.venv
文件夹并创建一个新的虚拟环境。
希望这些解决方案之一可以解决的问题!
标签:python,subprocess,python-wheel,torch-scatter From: 77709910