我正在尝试在我的 ubuntu 服务器上安装 torch-geometric-temporal。 但我不断遇到错误
ModuleNotFoundError: No module named 'torch'
。
您能给我一个提示,我可以做什么来解决这个错误吗?
以下是我迄今为止执行的步骤:
更新和升级 Ubuntu 20.04.6 LTS
sudo apt update && sudo apt upgrade -y
为我的 Python 3.10.13 设置 venv
python3 -m venv venv
激活venv
source venv/bin/activate
安装火炬和火炬几何时间
pip install torch
pip install torch-geometric-temporal
这是我收到的完整错误消息
(venv) ubuntu@dissknecht:~/myspace/trackgenerator$ pip install torch-geometric-temporal
Collecting torch-geometric-temporal
Downloading torch_geometric_temporal-0.54.0.tar.gz (48 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 48.1/48.1 kB 1.7 MB/s eta 0:00:00
Installing build dependencies ... done
Getting requirements to build wheel ... done
Installing backend dependencies ... done
Preparing metadata (pyproject.toml) ... done
Collecting decorator==4.4.2 (from torch-geometric-temporal)
Downloading decorator-4.4.2-py2.py3-none-any.whl.metadata (4.2 kB)
Requirement already satisfied: torch in ./venv/lib/python3.10/site-packages (from torch-geometric-temporal) (2.2.2)
Collecting cython (from torch-geometric-temporal)
Downloading Cython-3.0.9-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (3.2 kB)
Collecting pandas<=1.3.5 (from torch-geometric-temporal)
Downloading pandas-1.3.5-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (12 kB)
Collecting torch-sparse (from torch-geometric-temporal)
Downloading torch_sparse-0.6.18.tar.gz (209 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 210.0/210.0 kB 5.3 MB/s eta 0:00:00
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]
Traceback (most recent call last):
File "/home/ubuntu/myspace/trackgenerator/venv/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
main()
File "/home/ubuntu/myspace/trackgenerator/venv/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
json_out['return_val'] = hook(**hook_input['kwargs'])
File "/home/ubuntu/myspace/trackgenerator/venv/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 118, in get_requires_for_build_wheel
return hook(config_settings)
File "/tmp/pip-build-env-ep17iaup/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 325, in get_requires_for_build_wheel
return self._get_build_requires(config_settings, requirements=['wheel'])
File "/tmp/pip-build-env-ep17iaup/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 295, in _get_build_requires
self.run_setup()
File "/tmp/pip-build-env-ep17iaup/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 487, in run_setup
super().run_setup(setup_script=setup_script)
File "/tmp/pip-build-env-ep17iaup/overlay/lib/python3.10/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.
note: This error originates from a subprocess, and is likely not a problem with pip.
看起来
torch
已成功安装在您的虚拟环境 (venv
) 中,但是当 torch-geometric-temporal
尝试安装时,它在尝试构建轮子时遇到错误,特别是当它获得构建轮子的要求时轮子。
问题可能是
torch-geometric-temporal
依赖于 torch-sparse
,并且可能缺少一些依赖项或安装出现问题。
您可以尝试执行以下几个步骤来解决此问题:
重新安装torch-sparse:尝试手动重新安装
torch-sparse
,看看安装过程中是否有错误。
pip install torch-sparse --no-build-isolation
--no-build-isolation
标志可以帮助安装过程访问可能丢失的系统级依赖项。
检查是否缺少依赖项:确保您拥有构建所需的所有依赖项
torch-sparse
。有关任何特定依赖项,请参阅 torch-sparse
或 torch-geometric-temporal
的文档。
升级 pip 和 setuptools:有时,此类问题可以通过将
pip
和 setuptools
升级到最新版本来解决。
pip install --upgrade pip setuptools
检查系统要求:验证您的系统是否满足安装和运行
torch-geometric-temporal
及其依赖项的所有要求。
更新系统软件包:确保您的所有系统软件包都是最新的。有时,过时的系统包可能会导致与 Python 包发生冲突。
6.检查Python版本兼容性:确保您使用的Python版本与
torch-geometric-temporal
及其依赖项兼容。
尝试这些步骤,看看是否可以解决问题。如果问题仍然存在,您可能需要提供更多详细信息或查阅文档或支持渠道
torch-geometric-temporal
以获得进一步帮助。