在 Docker 上安装检测器 2 包

问题描述

我使用的是 python 3.7.9 版本。 dectron2 安装不正确。 命令: docker exec -it 1ee02b74a599 /bin/bash root@1ee02b74a599:/app# pip install detectionron2==0.2.1 -f https://dl.fbaipublicfiles.com/detectron2/wheels/cpu/torch1.4/index.html

安装过程中出现以下问题。

  *Building wheels for collected packages: pycocotools
  Building wheel for pycocotools (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: /opt/conda/bin/python -u -c 'import sys,setuptools,tokenize; sys.argv[0] = '"'"'/tmp/pip-install-nmjk8ssb/pycocotools/setup.py'"'"'; __file__='"'"'/tmp/pip-install-nmjk8ssb/pycocotools/setup.py'"'"';f=getattr(tokenize,'"'"'open'"'"',open)(__file__);code=f.read().replace('"'"'\r\n'"'"','"'"'\n'"'"');f.close();exec(compile(code,__file__,'"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-x7z500uh
       cwd: /tmp/pip-install-nmjk8ssb/pycocotools/
  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/mask.py -> build/lib.linux-x86_64-3.7/pycocotools
  copying pycocotools/cocoeval.py -> 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
  running build_ext
  cythoning pycocotools/_mask.pyx to pycocotools/_mask.c
  /opt/conda/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-nmjk8ssb/pycocotools/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 /opt/conda/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/Opt/conda/lib/python3.7/site-packages/numpy/core/include -I./common -I/Opt/conda/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*

解决方法

请检查您在 Dockerfile 中使用的 python 映像,也许您看到此错误的原因是您使用的是删除 gcc 以使其尽可能小的 alpine 或 slim 映像,然后使用这些映像像 python:3.7 或 ...

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...