PS C:\Users\peter> pip install git+https://github.com/philferriere/cocoapi.git#subdirectory=PythonAPI
Collecting git+https://github.com/philferriere/cocoapi.git#subdirectory=PythonAPI
Cloning https://github.com/philferriere/cocoapi.git to c:\users\peter\appdata\local\temp\pip-req-build-_9qbjwiy
Building wheels for collected packages: pycocotools
Running setup.py bdist_wheel for pycocotools ... error
Complete output from command d:\anaconda3\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\peter\\AppData\\Local\\Temp\\pip-req-build-_9qbjwiy\\PythonAPI\\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 C:\Users\peter\AppData\Local\Temp\pip-wheel-ccfig2_s --python-tag cp36:
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
building 'pycocotools._mask' extension
creating build\temp.win-amd64-3.6
creating build\temp.win-amd64-3.6\Release
creating build\temp.win-amd64-3.6\Release\pycocotools
creating build\temp.win-amd64-3.6\common
D:\Anaconda3\MinGW\bin\gcc.exe -mdll -O -Wall -DMS_WIN64 -Id:\anaconda3\lib\site-packages\numpy\core\include -I../common -Id:\anaconda3\include -Id:\anaconda3\include -c pycocotools/_mask.c -o build\temp.win-amd64-3.6\Release\pycocotools\_mask.o
In file included from d:\anaconda3\lib\site-packages\numpy\core\include/numpy/ndarraytypes.h:1816:0,
from d:\anaconda3\lib\site-packages\numpy\core\include/numpy/ndarrayobject.h:18,
from d:\anaconda3\lib\site-packages\numpy\core\include/numpy/arrayobject.h:4,
from pycocotools/_mask.c:590:
d:\anaconda3\lib\site-packages\numpy\core\include/numpy/npy_1_7_deprecated_api.h:12:9: note: #pragma message: d:\anaconda3\lib\site-packages\numpy\core\include/numpy/npy_1_7_deprecated_api.h(12) : Warning Msg: Using deprecated NumPy API, disable it by #defining NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
pycocotools/_mask.c: In function '__Pyx_ImportType':
pycocotools/_mask.c:16964:13: warning: unknown conversion type character 'z' in format [-Wformat]
pycocotools/_mask.c:16964:13: warning: unknown conversion type character 'z' in format [-Wformat]
pycocotools/_mask.c:16964:13: warning: too many arguments for format [-Wformat-extra-args]
D:\Anaconda3\MinGW\bin\gcc.exe -mdll -O -Wall -DMS_WIN64 -Id:\anaconda3\lib\site-packages\numpy\core\include -I../common -Id:\anaconda3\include -Id:\anaconda3\include -c ../common/maskApi.c -o build\temp.win-amd64-3.6\Release\..\common\maskapi.o
writing build\temp.win-amd64-3.6\Release\pycocotools\_mask.cp36-win_amd64.def
D:\Anaconda3\MinGW\bin\gcc.exe -shared -s build\temp.win-amd64-3.6\Release\pycocotools\_mask.o build\temp.win-amd64-3.6\Release\..\common\maskapi.o build\temp.win-amd64-3.6\Release\pycocotools\_mask.cp36-win_amd64.def -Ld:\anaconda3\libs -Ld:\anaconda3\PCbuild\amd64 -lpython36 -lmsvcr140 -o build\lib.win-amd64-3.6\pycocotools\_mask.cp36-win_amd64.pyd
d:/anaconda3/mingw/bin/../lib/gcc/x86_64-w64-mingw32/4.7.0/../../../../x86_64-w64-mingw32/bin/ld.exe: build\temp.win-amd64-3.6\Release\pycocotools\_mask.cp36-win_amd64.def:1: syntax error
d:/anaconda3/mingw/bin/../lib/gcc/x86_64-w64-mingw32/4.7.0/../../../../x86_64-w64-mingw32/bin/ld.exe:build\temp.win-amd64-3.6\Release\pycocotools\_mask.cp36-win_amd64.def: file format not recognized; treating as linker script
d:/anaconda3/mingw/bin/../lib/gcc/x86_64-w64-mingw32/4.7.0/../../../../x86_64-w64-mingw32/bin/ld.exe:build\temp.win-amd64-3.6\Release\pycocotools\_mask.cp36-win_amd64.def:1: syntax error
collect2.exe: error: ld returned 1 exit status
error: command 'D:\\Anaconda3\\MinGW\\bin\\gcc.exe' failed with exit status 1
----------------------------------------
Failed building wheel for pycocotools
Running setup.py clean for pycocotools
Complete output from command d:\anaconda3\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\peter\\AppData\\Local\\Temp\\pip-req-build-_9qbjwiy\\PythonAPI\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" clean --all:
Traceback (most recent call last):
File "", line 1, in
File "C:\Users\peter\AppData\Local\Temp\pip-req-build-_9qbjwiy\PythonAPI\setup.py", line 25, in
cythonize(ext_modules)
File "d:\anaconda3\lib\site-packages\Cython\Build\Dependencies.py", line 897, in cythonize
aliases=aliases)
File "d:\anaconda3\lib\site-packages\Cython\Build\Dependencies.py", line 777, in create_extension_list
for file in nonempty(sorted(extended_iglob(filepattern)), "'%s' doesn't match any files" % filepattern):
File "d:\anaconda3\lib\site-packages\Cython\Build\Dependencies.py", line 102, in nonempty
raise ValueError(error_msg)
ValueError: 'pycocotools/_mask.pyx' doesn't match any files
----------------------------------------
Failed cleaning build dir for pycocotools
Failed to build pycocotools
Installing collected packages: pycocotools
Running setup.py install for pycocotools ... error
Complete output from command d:\anaconda3\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\peter\\AppData\\Local\\Temp\\pip-req-build-_9qbjwiy\\PythonAPI\\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\peter\AppData\Local\Temp\pip-record-kjy7gqmp\install-record.txt --single-version-externally-managed --compile:
running install
running build
running build_py
running build_ext
building 'pycocotools._mask' extension
D:\Anaconda3\MinGW\bin\gcc.exe -mdll -O -Wall -DMS_WIN64 -Id:\anaconda3\lib\site-packages\numpy\core\include -I../common -Id:\anaconda3\include -Id:\anaconda3\include -c pycocotools/_mask.c -o build\temp.win-amd64-3.6\Release\pycocotools\_mask.o
In file included from d:\anaconda3\lib\site-packages\numpy\core\include/numpy/ndarraytypes.h:1816:0,
from d:\anaconda3\lib\site-packages\numpy\core\include/numpy/ndarrayobject.h:18,
from d:\anaconda3\lib\site-packages\numpy\core\include/numpy/arrayobject.h:4,
from pycocotools/_mask.c:590:
d:\anaconda3\lib\site-packages\numpy\core\include/numpy/npy_1_7_deprecated_api.h:12:9: note: #pragma message: d:\anaconda3\lib\site-packages\numpy\core\include/numpy/npy_1_7_deprecated_api.h(12) : Warning Msg: Using deprecated NumPy API, disable it by #defining NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
pycocotools/_mask.c: In function '__Pyx_ImportType':
pycocotools/_mask.c:16964:13: warning: unknown conversion type character 'z' in format [-Wformat]
pycocotools/_mask.c:16964:13: warning: unknown conversion type character 'z' in format [-Wformat]
pycocotools/_mask.c:16964:13: warning: too many arguments for format [-Wformat-extra-args]
D:\Anaconda3\MinGW\bin\gcc.exe -mdll -O -Wall -DMS_WIN64 -Id:\anaconda3\lib\site-packages\numpy\core\include -I../common -Id:\anaconda3\include -Id:\anaconda3\include -c ../common/maskApi.c -o build\temp.win-amd64-3.6\Release\..\common\maskapi.o
writing build\temp.win-amd64-3.6\Release\pycocotools\_mask.cp36-win_amd64.def
D:\Anaconda3\MinGW\bin\gcc.exe -shared -s build\temp.win-amd64-3.6\Release\pycocotools\_mask.o build\temp.win-amd64-3.6\Release\..\common\maskapi.o build\temp.win-amd64-3.6\Release\pycocotools\_mask.cp36-win_amd64.def -Ld:\anaconda3\libs -Ld:\anaconda3\PCbuild\amd64 -lpython36 -lmsvcr140 -o build\lib.win-amd64-3.6\pycocotools\_mask.cp36-win_amd64.pyd
d:/anaconda3/mingw/bin/../lib/gcc/x86_64-w64-mingw32/4.7.0/../../../../x86_64-w64-mingw32/bin/ld.exe: build\temp.win-amd64-3.6\Release\pycocotools\_mask.cp36-win_amd64.def:1: syntax error
d:/anaconda3/mingw/bin/../lib/gcc/x86_64-w64-mingw32/4.7.0/../../../../x86_64-w64-mingw32/bin/ld.exe:build\temp.win-amd64-3.6\Release\pycocotools\_mask.cp36-win_amd64.def: file format not recognized; treating as linker script
d:/anaconda3/mingw/bin/../lib/gcc/x86_64-w64-mingw32/4.7.0/../../../../x86_64-w64-mingw32/bin/ld.exe:build\temp.win-amd64-3.6\Release\pycocotools\_mask.cp36-win_amd64.def:1: syntax error
collect2.exe: error: ld returned 1 exit status
error: command 'D:\\Anaconda3\\MinGW\\bin\\gcc.exe' failed with exit status 1
原因是编译安装时python用的mingw32的gcc而不是用msvc,因此一直有些问题
solution:
python
安装目录(anaconda目录),找到Lib
,进入distutils
包,进入找到distutils.cfg
文件[build]
compiler=mingw32
改为:
[build]
compiler=msvc
3.pip install git+https://github.com/philferriere/cocoapi.git#subdirectory=PythonAPI
PS C:\Users\peter> pip install git+https://github.com/philferriere/cocoapi.git#subdirectory=PythonAPI
Collecting git+https://github.com/philferriere/cocoapi.git#subdirectory=PythonAPI
Cloning https://github.com/philferriere/cocoapi.git to c:\users\peter\appdata\local\temp\pip-req-build-_5h_zx6o
Building wheels for collected packages: pycocotools
Running setup.py bdist_wheel for pycocotools ... done
Stored in directory: C:\Users\peter\AppData\Local\Temp\pip-ephem-wheel-cache-f2p0wo9j\wheels\69\2b\12\2fa959e49f73d26cff202c2f4e5079096c9c57c8a8509fd75c
Successfully built pycocotools
Installing collected packages: pycocotools
Successfully installed pycocotools-2.0
You are using pip version 10.0.1, however version 18.0 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.
这里是这个文件的地址,有需要的小伙伴可以自行下载
https://gist.github.com/cgpeter96/c56d28798faec5e689cf6139e8341d39