본문 바로가기

프로그래밍/Python

windows 에서 pip install pycocotools 로 설치가 안 된다.

반응형

2020년 6월 18일

윈도우 10, Python 3.7-64, 환경에서 pip install pycocotools 명령으로 설치를 진행하였으나, 에러가 발생하였다.

에러메시지

  Running setup.py clean for pycocotools
Failed to build pycocotools
Installing collected packages: pycocotools
    Running setup.py install for pycocotools ... error
    ERROR: Command errored out with exit status 1:
     command: 'd:\pyenvs\aigpu_tf2_3764\scripts\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\userme\\AppData\\Local\\Temp\\pip-install-nweofm94\\pycocotools\\setup.py'"'"'; __file__='"'"'C:\\Users\\userme\\AppData\\Local\\Temp\\pip-install-nweofm94\\pycocotools\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\userme\AppData\Local\Temp\pip-record-uc9iw8q0\install-record.txt' --single-version-externally-managed --compile --install-headers 'd:\pyenvs\aigpu_tf2_3764\include\site\python3.7\pycocotools'
         cwd: C:\Users\userme\AppData\Local\Temp\pip-install-nweofm94\pycocotools\
    Complete output (20 lines):
    running install
    running build
    running build_py
    creating build
    creating build\lib.win-amd64-3.7
    creating build\lib.win-amd64-3.7\pycocotools
    copying pycocotools\coco.py -> build\lib.win-amd64-3.7\pycocotools
    copying pycocotools\cocoeval.py -> build\lib.win-amd64-3.7\pycocotools
    copying pycocotools\mask.py -> build\lib.win-amd64-3.7\pycocotools
    copying pycocotools\__init__.py -> build\lib.win-amd64-3.7\pycocotools
    running build_ext
    skipping 'pycocotools\_mask.c' Cython extension (up-to-date)
    building 'pycocotools._mask' extension
    creating build\temp.win-amd64-3.7
    creating build\temp.win-amd64-3.7\Release
    creating build\temp.win-amd64-3.7\Release\common
    creating build\temp.win-amd64-3.7\Release\pycocotools
    C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Id:\pyenvs\aigpu_tf2_3764\lib\site-packages\numpy\core\include -I./common -Id:\pyenvs\aigpu_tf2_3764\include 
-ID:\Python3764\include -ID:\Python3764\include "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE" "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\ATLMFC\INCLUDE" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.14393.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\include\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.14393.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.14393.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.14393.0\winrt" /Tc./common/maskApi.c /Fobuild\temp.win-amd64-3.7\Release\./common/maskApi.obj -Wno-cpp -Wno-unused-function -std=c99
    cl : 명령줄 error D8021 : '/Wno-cpp' 숫자 인수가 잘못되었습니다.
    error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\x86_amd64\\cl.exe' failed with exit status 2
    ----------------------------------------
ERROR: Command errored out with exit status 1: 'd:\pyenvs\aigpu_tf2_3764\scripts\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\userme\\AppData\\Local\\Temp\\pip-install-nweofm94\\pycocotools\\setup.py'"'"'; __file__='"'"'C:\\Users\\userme\\AppData\\Local\\Temp\\pip-install-nweofm94\\pycocotools\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\userme\AppData\Local\Temp\pip-record-uc9iw8q0\install-record.txt' --single-version-externally-managed --compile --install-headers 'd:\pyenvs\aigpu_tf2_3764\include\site\python3.7\pycocotools' Check the logs for full command output.

문제를 해결하기 위해 구글링을 하니, https://github.com/cocodataset/cocoapi/issues/169 에 이 문제에 대한 github issue 타래가 있었다.

윈도우는 지원을 하지 않는다는 답변이 달려 있어서, 낙담하고 있었는데, 윈도우용 레포를 사용하는 방법을 친절하게 써 놓은 친구가 있었다.

https://github.com/cocodataset/cocoapi/issues/169#issuecomment-462528628

pip3 install "git+https://github.com/philferriere/cocoapi.git#egg=pycocotools&subdirectory=PythonAPI"

git이 깔려 있어야 한다. 비주얼 스튜디오 2015도 깔려 있어야 한다고는 하는데, 정말필요한 건지는 모르겠다.

아무튼 위 명령을 커맨드창에 입력하여 실행하니, 설치가 잘 됐다.

C:\User\userme\work> pip3 install "git+https://github.com/philferriere/cocoapi.git#egg=pycocotools&subdirectory=PythonAPI"
Looking in indexes: http://192.168.123.210:7000/simple
Collecting pycocotools
  Cloning https://github.com/philferriere/cocoapi.git to c:\users\daewon\appdata\local\temp\pip-install-34jtxafn\pycocotools
  Running command git clone -q https://github.com/philferriere/cocoapi.git 'C:\Users\daewon\AppData\Local\Temp\pip-install-34jtxafn\pycocotools'
Building wheels for collected packages: pycocotools
  Building wheel for pycocotools (setup.py) ... done
  Created wheel for pycocotools: filename=pycocotools-2.0-cp37-cp37m-win_amd64.whl size=79782 sha256=319ae2d1cc2e24e10c0e52137ba07172a4872d2d2071bd04eb1795ff4858cdb2
  Stored in directory: C:\Users\daewon\AppData\Local\Temp\pip-ephem-wheel-cache-zdi9j1dt\wheels\6b\c6\c5\cb6da4cb793a6cb1ab91f6578d76c42686422127eb4dbcea94
Successfully built pycocotools
Installing collected packages: pycocotools
Successfully installed pycocotools-2.0
728x90