pycocotools安装失败 compiler_compat/ld

项目场景:

安装pycocotools出现的问题,python版本是3.6.9,在conda环境下:

1
2
3
4
5
6
7
8
gcc -pthread -shared -B /home/hm/anaconda3/envs/lan/compiler_compat -L/home/hm/anaconda3/envs/lan/lib -Wl,-rpath=/home/hm/anaconda3/envs/lan/lib -Wl,--no-as-needed -Wl,--sysroot=/ build/temp.linux-x86_64-3.6/../common/maskApi.o build/temp.linux-x86_64-3.6/pycocotools/_mask.o -o build/lib.linux-x86_64-3.6/pycocotools/_mask.cpython-36m-x86_64-linux-gnu.so
/home/hm/anaconda3/envs/xxx/compiler_compat/ld: build/temp.linux-x86_64-3.6/../common/maskApi.o: unable to initialize decompress status for section .debug_info
/home/hm/anaconda3/envs/xxx/compiler_compat/ld: build/temp.linux-x86_64-3.6/../common/maskApi.o: unable to initialize decompress status for section .debug_info
/home/hm/anaconda3/envs/xxx/compiler_compat/ld: build/temp.linux-x86_64-3.6/../common/maskApi.o: unable to initialize decompress status for section .debug_info
/home/hm/anaconda3/envs/xxx/compiler_compat/ld: build/temp.linux-x86_64-3.6/../common/maskApi.o: unable to initialize decompress status for section .debug_info
build/temp.linux-x86_64-3.6/../common/maskApi.o: file not recognized: file format not recognized
collect2: 错误: ld 返回 1
error: command 'gcc' failed with exit status 1</font>

问题描述:

安装pycocotools失败

原因分析:

应该是系统动态链接库和conda环境里的库哪里出了问题,从错误信息里看出gcc使用的是conda环境里的ld,


解决方案:

尝试使用系统的ld,因为如果找不到conda里的ld,会自动使用系统的ld
cd到anaconda下环境的目录里,把ld这个文件暂时改成其他名字
不过只是临时解决而已,可能是我操作不当引起的问题