在Windows下安装pycocotools,执行pip install pycocotools
报错
pip install pycocotools
这是报错信息:
Looking in indexes: https://mirrors.aliyun.com/pypi/simple/
Collecting pycocotools
Using cached https://mirrors.aliyun.com/pypi/packages/de/df/056875d697c45182ed6d2ae21f62015896fdb841906fe48e7268e791c467/pycocotools-2.0.2.tar.gz (23 kB)
Requirement already satisfied: setuptools>=18.0 in d:\anaconda3\envs\test\lib\site-packages (from pycocotools) (52.0.0.post20210125)
Requirement already satisfied: cython>=0.27.3 in d:\anaconda3\envs\test\lib\site-packages (from pycocotools) (0.29.24)
Requirement already satisfied: matplotlib>=2.1.0 in d:\anaconda3\envs\test\lib\site-packages (from pycocotools) (3.3.4)
Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.3 in d:\anaconda3\envs\test\lib\site-packages (from matplotlib>=2.1.0->pycocotools) (2.4.7)
Requirement already satisfied: pillow>=6.2.0 in d:\anaconda3\envs\test\lib\site-packages (from matplotlib>=2.1.0->pycocotools) (8.3.1)
Requirement already satisfied: cycler>=0.10 in d:\anaconda3\envs\test\lib\site-packages (from matplotlib>=2.1.0->pycocotools) (0.10.0)
Requirement already satisfied: kiwisolver>=1.0.1 in d:\anaconda3\envs\test\lib\site-packages (from matplotlib>=2.1.0->pycocotools) (1.3.1)
Requirement already satisfied: numpy>=1.15 in d:\anaconda3\envs\test\lib\site-packages (from matplotlib>=2.1.0->pycocotools) (1.19.5)
Requirement already satisfied: python-dateutil>=2.1 in d:\anaconda3\envs\test\lib\site-packages (from matplotlib>=2.1.0->pycocotools) (2.8.2)
Requirement already satisfied: six in d:\anaconda3\envs\test\lib\site-packages (from cycler>=0.10->matplotlib>=2.1.0->pycocotools) (1.15.0)
Building wheels for collected packages: pycocotools
Building wheel for pycocotools (setup.py) ... error
ERROR: Command errored out with exit status 1:
command: 'D:\Anaconda3\envs\test\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Admin\\AppData\\Local\\Temp\\pip-install-f4erarxu\\pycocotools_6c866ebd872c45c98ae6a3f297991530\\setup.py'"'"'; __file__='"'"'C:\\Users\\Admin\\AppData\\Local\\Temp\\pip-install-f4erarxu\\pycocotools_6c866ebd872c45c98ae6a3f297991530\\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 'C:\Users\Admin\AppData\Local\Temp\pip-wheel-fnkglyms'
cwd: C:\Users\Admin\AppData\Local\Temp\pip-install-f4erarxu\pycocotools_6c866ebd872c45c98ae6a3f297991530\
Complete output (16 lines):
running bdist_wheel
running build
running build_py
creating build
creating build\lib.win-amd64-3.6
creating build\lib.win-amd64-3.6\pycocotools
copying pycocotools\coco.py -> build\lib.win-amd64-3.6\pycocotools
copying pycocotools\cocoeval.py -> build\lib.win-amd64-3.6\pycocotools
copying pycocotools\mask.py -> build\lib.win-amd64-3.6\pycocotools
copying pycocotools\__init__.py -> build\lib.win-amd64-3.6\pycocotools
running build_ext
cythoning pycocotools/_mask.pyx to pycocotools\_mask.c
D:\Anaconda3\envs\test\lib\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: C:\Users\Admin\AppData\Local\Temp\pip-install-f4erarxu\pycocotools_6c866ebd872c45c98ae6a3f297991530\pycocotools\_mask.pyx
tree = Parsing.p_module(s, pxd, full_module_name)
building 'pycocotools._mask' extension
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/
----------------------------------------
ERROR: Failed building wheel for 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:\Anaconda3\envs\test\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Admin\\AppData\\Local\\Temp\\pip-install-f4erarxu\\pycocotools_6c866ebd872c45c98ae6a3f297991530\\setup.py'"'"'; __file__='"'"'C:\\Users\\Admin\\AppData\\Local\\Temp\\pip-install-f4erarxu\\pycocotools_6c866ebd872c45c98ae6a3f297991530\\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'"'"'))' install --record 'C:\Users\Admin\AppData\Local\Temp\pip-record-l28knydp\install-record.txt' --single-version-externally-managed --compile --install-headers 'D:\Anaconda3\envs\test\Include\pycocotools'
cwd: C:\Users\Admin\AppData\Local\Temp\pip-install-f4erarxu\pycocotools_6c866ebd872c45c98ae6a3f297991530\
Complete output (14 lines):
running install
running build
running build_py
creating build
creating build\lib.win-amd64-3.6
creating build\lib.win-amd64-3.6\pycocotools
copying pycocotools\coco.py -> build\lib.win-amd64-3.6\pycocotools
copying pycocotools\cocoeval.py -> build\lib.win-amd64-3.6\pycocotools
copying pycocotools\mask.py -> build\lib.win-amd64-3.6\pycocotools
copying pycocotools\__init__.py -> build\lib.win-amd64-3.6\pycocotools
running build_ext
skipping 'pycocotools\_mask.c' Cython extension (up-to-date)
building 'pycocotools._mask' extension
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/
----------------------------------------
ERROR: Command errored out with exit status 1: 'D:\Anaconda3\envs\test\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Admin\\AppData\\Local\\Temp\\pip-install-f4erarxu\\pycocotools_6c866ebd872c45c98ae6a3f297991530\\setup.py'"'"'; __file__='"'"'C:\\Users\\Admin\\AppData\\Local\\Temp\\pip-install-f4erarxu\\pycocotools_6c866ebd872c45c98ae6a3f297991530\\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'"'"'))' install --record 'C:\Users\Admin\AppData\Local\Temp\pip-record-l28knydp\install-record.txt' --single-version-externally-managed --compile --install-headers 'D:\Anaconda3\envs\test\Include\pycocotools' Check the logs for full command output.
正确安装:
pip install pycocotools-windows