当前位置: 首页 > news >正文

error: subprocess-exited-with-error【已解决】

问题详述

安装mmdetection的时候出现了如下错误:

(mmdet) [root@localhost mmdetection]# Using pip 25.1.1 from /root/mmdet/lib64/python3.9/site-packages/pip (python 3.9)
-bash: syntax error near unexpected token `('
(mmdet) [root@localhost mmdetection]# Obtaining file:///root/mmdetectionRunning command Checking if build backend supports build_editableChecking if build backend supports build_editable ... doneRunning command Preparing metadata (pyproject.toml)running dist_info
-bash: Obtaining: command not foundcreating /tmp/pip-modern-metadata-g_g33xul/mmdet.egg-infowriting manifest file '/tmp/pip-modern-metadata-g_g33xul/mmdet.egg-info/SOURCES.txt'warning: no files found matching 'mmdet/VERSION'warning: no files found matching 'mmdet/.mim/demo/*/*'writing manifest file '/tmp/pip-modern-metadata-g_g33xul/mmdet.egg-info/SOURCES.txt'error: invalid command 'bdist_wheel'error: subprocess-exited-with-error× Preparing metadata (pyproject.toml) did not run successfully.│ exit code: 1╰─> See above for output.

解决方法

# 4. 进入项目目录
cd ~/mmdetection# 5. 安装构建依赖
pip install -r requirements/build.txt
pip install -r requirements/optional.txt# 6. 预构建扩展
python setup.py build_ext# 7. 安装MMDetection
python setup.py develop

如果不行可以从下面的方式中找解决方法

1. 确保环境干净
# 退出当前虚拟环境
deactivate# 删除现有虚拟环境
rm -rf ~/mmdet# 创建新的虚拟环境
python -m venv ~/mmdet
source ~/mmdet/bin/activate
2. 安装基础依赖
# 更新pip和安装必要工具
pip install --upgrade pip setuptools wheel# 安装系统依赖
sudo yum install geos-devel python3-devel gcc-c++ -y# 安装NumPy开发头文件
pip install numpy cython
3. 修复MMDetection安装问题
# 进入项目目录
cd ~/mmdetection# 先安装构建依赖
pip install -r requirements/build.txt
pip install -r requirements/optional.txt# 生成版本文件(解决VERSION警告)
python setup.py build_ext# 安装MMDetection(使用开发模式)
python setup.py develop
4. 替代安装方法(如果上述失败)
# 使用openmim安装
pip install openmim
mim install -e .
5. 验证安装
# 检查MMDetection是否安装成功
python -c "import mmdet; print(mmdet.__version__)"# 测试是否可以导入
python -c "from mmdet.apis import init_detector; print('Success!')"

如果仍然遇到问题

方案A:手动安装所有依赖
# 安装所有requirements中的依赖
for req in $(ls requirements/*.txt); dopip install -r $req
done# 然后尝试安装
python setup.py develop
方案B:使用Docker安装
# 使用官方MMDetection Docker镜像
docker pull mmdetection/mmdetection:latest# 或者自己构建
docker build -t mmdetection . -f docker/Dockerfile
方案C:检查项目完整性
# 确保项目文件完整
git status
git reset --hard
git clean -fdx# 重新克隆项目
cd ~
rm -rf mmdetection
git clone https://github.com/open-mmlab/mmdetection.git
cd mmdetection

完整安装脚本

#!/bin/bash# 1. 创建并激活虚拟环境
python -m venv ~/mmdet
source ~/mmdet/bin/activate# 2. 安装系统依赖
sudo yum install geos-devel python3-devel gcc-c++ -y# 3. 更新pip和安装基础包
pip install --upgrade pip setuptools wheel numpy cython# 4. 进入项目目录
cd ~/mmdetection# 5. 安装构建依赖
pip install -r requirements/build.txt
pip install -r requirements/optional.txt# 6. 预构建扩展
python setup.py build_ext# 7. 安装MMDetection
python setup.py develop# 8. 验证安装
python -c "import mmdet; print(f'MMDetection version: {mmdet.__version__}')"

注意事项

  1. 不要复制粘贴命令输出

    • 只执行命令本身,不要复制粘贴命令的输出结果
  2. 权限问题

    • 避免使用root用户,如果必须使用,请确保环境一致
    sudo chown -R $USER:$USER ~/mmdet
    sudo chown -R $USER:$USER ~/mmdetection
    
  3. 日志分析

    • 如果安装失败,检查详细日志:
    pip install -v -e . 2>&1 | tee install.log
    
  4. 版本兼容性

    • 确保Python版本(3.6-3.9)与MMDetection兼容
    • 确保PyTorch版本匹配

这些步骤应该能解决您遇到的 bdist_wheel 错误和文件找不到的问题。关键是确保安装所有构建依赖并预先构建扩展模块。


文章转载自:

http://oUNpAVdy.zxhpx.cn
http://V5xnW9sh.zxhpx.cn
http://dtXuDlBp.zxhpx.cn
http://P8aXjx4c.zxhpx.cn
http://6023MlvB.zxhpx.cn
http://oEg9PReo.zxhpx.cn
http://vWNKcfNs.zxhpx.cn
http://zFbxFvLI.zxhpx.cn
http://h7Cwpzto.zxhpx.cn
http://ZqSPrbpA.zxhpx.cn
http://SLDaxSee.zxhpx.cn
http://r5crskDH.zxhpx.cn
http://AeEbWbYB.zxhpx.cn
http://oXTdgECa.zxhpx.cn
http://GGivUH15.zxhpx.cn
http://fRK5jnGr.zxhpx.cn
http://bDGVIaPs.zxhpx.cn
http://cww06DMd.zxhpx.cn
http://tPsVeRdX.zxhpx.cn
http://T3oQbuDo.zxhpx.cn
http://PhETe2mP.zxhpx.cn
http://0m94N5Lb.zxhpx.cn
http://xZPnCW7T.zxhpx.cn
http://rgWytHEX.zxhpx.cn
http://YHhtLRJH.zxhpx.cn
http://98FmliUv.zxhpx.cn
http://8lKonTI5.zxhpx.cn
http://12nSws6F.zxhpx.cn
http://RubHxYfQ.zxhpx.cn
http://vtgO5QY8.zxhpx.cn
http://www.dtcms.com/a/235747.html

相关文章:

  • SCAU数值计算OJ
  • 2.1 Windows编译环境介绍
  • 《UE5_C++多人TPS完整教程》学习笔记37 ——《P38 变量复制(Variable Replication)》
  • WinCC学习系列-变量模拟器(WinCC TAG Simulator )
  • MajicTryOn(基于wanvideo的虚拟试穿项目)
  • @Minikube 部署与配置
  • 使用 Python 构建并调用 ComfyUI 图像生成 API:完整实战指南
  • 【大厂机试题解法笔记】观看文艺演出问题
  • 使用扩散模型解决Talking Head生成中的头像抖动问题
  • 毫米波雷达基础理论(3D+4D)
  • 20250606-C#知识:匿名函数、Lambda表达式与闭包
  • C#中datagridview单元格value为{}大括号
  • Compose基本介绍
  • 8.1_排序的基本概念
  • 【C++】24. 哈希表的实现
  • Day46
  • 消息队列高级特性与原理:解锁分布式系统的底层逻辑
  • 【信息系统项目管理师-论文真题】2025上半年(第一批)论文详解(包括解题思路和写作要点)
  • 【大模型LLM学习】Flash-Attention的学习记录
  • PL/SQLDeveloper中数值类型字段查询后显示为科学计数法的处理方式
  • 主流定位技术:Zigbee、蓝牙、UWB、RFID、5G通信介绍及对比
  • PCB特种工艺应用扩展:厚铜、高频与软硬结合板
  • 视觉SLAM基础补盲
  • 【Kotlin】协程
  • 准确--k8s cgroup问题排查
  • 紫光同创FPGA系列实现Aurora 8b/10b协议
  • 单芯片电流采用电路分享
  • Tongweb配置跳过扫描应用jar的配置指引(by lqw)
  • 山东大学算法设计与分析复习笔记
  • 【PhysUnits】16.2 引入变量后的乘法实现(mul.rs)