在安装mmdetection时发现报缺少torch但明明已经安装ModuleNotFoundError: No module named ‘torch‘ [end of output]
·
报错背景:
编译安装一个mmdetection库时,明明已经安装了torch库但仍然报没有安装。
root@bms-covacs:/testcodes/jh/mx_data/fcos3d/DrivingSDK/model_examples/FCOS3D/mmdetection# pip install -e .
Looking in indexes: http://mirrors.aliyun.com/pypi/simple
Obtaining file:///testcodes/jh/mx_data/fcos3d/DrivingSDK/model_examples/FCOS3D/mmdetection
Installing build dependencies ... done
Checking if build backend supports build_editable ... done
Getting requirements to build editable ... error
error: subprocess-exited-with-error
× Getting requirements to build editable did not run successfully.
│ exit code: 1
╰─> [19 lines of output]
Traceback (most recent call last):
File "/usr/local/python3.9.18/lib/python3.9/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 389, in <module>
main()
File "/usr/local/python3.9.18/lib/python3.9/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 373, in main
json_out["return_val"] = hook(**hook_input["kwargs"])
File "/usr/local/python3.9.18/lib/python3.9/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 157, in get_requires_for_build_editable
return hook(config_settings)
File "/tmp/pip-build-env-1ivlvcst/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 483, in get_requires_for_build_editable
return self.get_requires_for_build_wheel(config_settings)
File "/tmp/pip-build-env-1ivlvcst/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 334, in get_requires_for_build_wheel
return self._get_build_requires(config_settings, requirements=[])
File "/tmp/pip-build-env-1ivlvcst/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 304, in _get_build_requires
self.run_setup()
File "/tmp/pip-build-env-1ivlvcst/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 522, in run_setup
super().run_setup(setup_script=setup_script)
File "/tmp/pip-build-env-1ivlvcst/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 320, in run_setup
exec(code, locals())
File "<string>", line 11, 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 editable 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.
root@bms-covacs:/testcodes/jh/mx_data/fcos3d/DrivingSDK/model_examples/FCOS3D/mmdetection# pip list | grep torch
torch 2.1.0
torch-npu 2.1.0.post11.dev20250211
torchvision 0.16.0
解决办法
pip cache purge
pip install --upgrade setuptools wheel
再次安装,成功了
root@bms-covacs:/testcodes/jh/mx_data/fcos3d/DrivingSDK/model_examples/FCOS3D/mmdetection# pip install -e .
Looking in indexes: http://mirrors.aliyun.com/pypi/simple
Obtaining file:///testcodes/jh/mx_data/fcos3d/DrivingSDK/model_examples/FCOS3D/mmdetection
Preparing metadata (setup.py) ... done
Requirement already satisfied: matplotlib in /usr/local/python3.9.18/lib/python3.9/site-packages (from mmdet==3.3.0) (3.9.4)
Requirement already satisfied: numpy in /usr/local/python3.9.18/lib/python3.9/site-packages (from mmdet==3.3.0) (1.25.0)
Requirement already satisfied: pycocotools in /usr/local/python3.9.18/lib/python3.9/site-packages (from mmdet==3.3.0) (2.0.8)
Requirement already satisfied: scipy in /usr/local/python3.9.18/lib/python3.9/site-packages (from mmdet==3.3.0) (1.13.1)
Requirement already satisfied: shapely in /usr/local/python3.9.18/lib/python3.9/site-packages (from mmdet==3.3.0) (2.0.7)
Requirement already satisfied: six in /usr/local/python3.9.18/lib/python3.9/site-packages (from mmdet==3.3.0) (1.17.0)
Requirement already satisfied: terminaltables in /usr/local/python3.9.18/lib/python3.9/site-packages (from mmdet==3.3.0) (3.1.10)
Requirement already satisfied: tqdm in /usr/local/python3.9.18/lib/python3.9/site-packages (from mmdet==3.3.0) (4.67.1)
Requirement already satisfied: contourpy>=1.0.1 in /usr/local/python3.9.18/lib/python3.9/site-packages (from matplotlib->mmdet==3.3.0) (1.3.0)
Requirement already satisfied: cycler>=0.10 in /usr/local/python3.9.18/lib/python3.9/site-packages (from matplotlib->mmdet==3.3.0) (0.12.1)
Requirement already satisfied: fonttools>=4.22.0 in /usr/local/python3.9.18/lib/python3.9/site-packages (from matplotlib->mmdet==3.3.0) (4.56.0)
Requirement already satisfied: kiwisolver>=1.3.1 in /usr/local/python3.9.18/lib/python3.9/site-packages (from matplotlib->mmdet==3.3.0) (1.4.7)
Requirement already satisfied: packaging>=20.0 in /usr/local/python3.9.18/lib/python3.9/site-packages (from matplotlib->mmdet==3.3.0) (24.2)
Requirement already satisfied: pillow>=8 in /usr/local/python3.9.18/lib/python3.9/site-packages (from matplotlib->mmdet==3.3.0) (11.1.0)
Requirement already satisfied: pyparsing>=2.3.1 in /usr/local/python3.9.18/lib/python3.9/site-packages (from matplotlib->mmdet==3.3.0) (3.2.1)
Requirement already satisfied: python-dateutil>=2.7 in /usr/local/python3.9.18/lib/python3.9/site-packages (from matplotlib->mmdet==3.3.0) (2.9.0.post0)
Requirement already satisfied: importlib-resources>=3.2.0 in /usr/local/python3.9.18/lib/python3.9/site-packages (from matplotlib->mmdet==3.3.0) (6.5.2)
Requirement already satisfied: zipp>=3.1.0 in /usr/local/python3.9.18/lib/python3.9/site-packages (from importlib-resources>=3.2.0->matplotlib->mmdet==3.3.0) (3.21.0)
Installing collected packages: mmdet
DEPRECATION: Legacy editable install of mmdet==3.3.0 from file:///testcodes/jh/mx_data/fcos3d/DrivingSDK/model_examples/FCOS3D/mmdetection (setup.py develop) is deprecated. pip 25.1 will enforce this behaviour change. A possible replacement is to add a pyproject.toml or enable --use-pep517, and use setuptools >= 64. If the resulting installation is not behaving as expected, try using --config-settings editable_mode=compat. Please consult the setuptools documentation for more information. Discussion can be found at https://github.com/pypa/pip/issues/11457
Running setup.py develop for mmdet
Successfully installed mmdet
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager, possibly rendering your system unusable. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv. Use the --root-user-action option if you know what you are doing and want to suppress this warning.
更多推荐

所有评论(0)