项目场景:
系统:ubuntu16.04
安装yolov5,直接pip install requirements.txt,报错
问题描述:
报错信息如下,可见是pycocotools安装错误
Building wheels for collected packages: pycocotools
Building wheel for pycocotools (setup.py) ... error
ERROR: Command errored out with exit status 1:
command: /root/anaconda3/envs/yolov5/bin/python -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-hemp_z72/pycocotools_a290c0ec5b984c809bb56fa10ca801ce/setup.py'"'"'; __file__='"'"'/tmp/pip-install-hemp_z72/pycocotools_a290c0ec5b984c809bb56fa10ca801ce/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-kkrnoozi
cwd: /tmp/pip-install-hemp_z72/pycocotools_a290c0ec5b984c809bb56fa10ca801ce/
Complete output (21 lines):
running bdist_wheel
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.7
creating build/lib.linux-x86_64-3.7/pycocotools
copying pycocotools/__init__.py -> build/lib.linux-x86_64-3.7/pycocotools
copying pycocotools/coco.py -> build/lib.linux-x86_64-3.7/pycocotools
copying pycocotools/mask.py -> build/lib.linux-x86_64-3.7/pycocotools
copying pycocotools/cocoeval.py -> build/lib.linux-x86_64-3.7/pycocotools
running build_ext
cythoning pycocotools/_mask.pyx to pycocotools/_mask.c
/root/anaconda3/envs/yolov5/lib/python3.7/site-packages/Cython/Compiler/Main.py:369: FutureWarning: Cython directive 'language_level' not set, using 2 for now (Py2). This will change in a later release! File: /tmp/pip-install-hemp_z72/pycocotools_a290c0ec5b984c809bb56fa10ca801ce/pycocotools/_mask.pyx
tree = Parsing.p_module(s, pxd, full_module_name)
building 'pycocotools._mask' extension
creating build/temp.linux-x86_64-3.7
creating build/temp.linux-x86_64-3.7/common
creating build/temp.linux-x86_64-3.7/pycocotools
gcc -pthread -B /root/anaconda3/envs/yolov5/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/root/anaconda3/envs/yolov5/lib/python3.7/site-packages/numpy/core/include -I./common -I/root/anaconda3/envs/yolov5/include/python3.7m -c ./common/maskApi.c -o build/temp.linux-x86_64-3.7/./common/maskApi.o -Wno-cpp -Wno-unused-function -std=c99
unable to execute 'gcc': No such file or directory
error: command 'gcc' failed with exit status 1
----------------------------------------
ERROR: Failed building wheel for pycocotools
Running setup.py clean for pycocotools
Failed to build pycocotools
解决方案:
出现这种情况的原因在于gcc未正确安装,导致系统找不到gcc安装位置,重新安装,如下
sudo apt-get install gcc
再安装pycocotools即可
pip install pycocotools -i https://pypi.doubanio.com/simple/ --trusted-host pypi.doubanio.com