본문 바로가기
AI/파이썬

pycocotools 패키지 설치 오류

by 알푼 2023. 8. 7.
728x90
728x90

coco dataset을 확인하기 위해서 pycocotools 라는 패키지가 필요하다. 그런데 해당 패키지를 설치하는 도중 에러가 발생하였다.

 

해결책1. git을 통해서 다운로드

가장 많이 나오는 해결책이다. 아래 명령어를 통해서 패키지를 받는다. 하지만 나는 여기에서도 오류가 발생하였다.

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

 

해결책2. pip install pycocotools-windows

윈도우 환경에서 사용하기 때문에 이런식으로 설치하는 것이다. 하지만 나는 이것도 실패…

 

해결책3. github 파일 수정

git clone https://github.com/pdollar/coco.git

위 명령어를 통해서 github 코드를 받은 후

coco/PythonAPI 경로로 진입하여 setup.py 파일을 일부 수정한다.

이 부분을

extra_compile_args=['-Wno-cpp', '-Wno-unused-function', '-std=c99'],

→ 이렇게 수정한다

extra_compile_args=['-std=c99'],

저장 후 python setup.py install

하지만 이것도 실패..

이 때 확인한 에러 메세지

error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/

 

해결책4. Microsoft Visual C++ 14.0 다운로드

에러 메세지가 너무 길다고 스킵하면 이런 부작용이 발생한다 ㅠㅠ

Microsoft Visual C++ 14.0 다운로드 후 설치하면 가볍게 해결된다.

아래 사이트에서 다음과 같이 설치하면 된다.

https://visualstudio.microsoft.com/visual-cpp-build-tools/

 

Microsoft C++ Build Tools - Visual Studio

The Microsoft C++ Build Tools provides MSVC toolsets via a scriptable, standalone installer without Visual Studio. Recommended if you build C++ libraries and applications targeting Windows from the command-line (e.g. as part of your continuous integration

visualstudio.microsoft.com

728x90
반응형

댓글