背景安装pycocotools一直过不去,一直报错
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 “<string>”, line 1, in <module>
File “C:\Users\peter\AppData\Local\Temp\pip-req-build-_9qbjwiy\PythonAPI\setup.py”, line 25, in <module>
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
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
- 85
- 86
解决方法
原因是编译安装时python用的mingw32的gcc而不是用msvc,因此一直有些问题
solution:
- 进入
python
安装目录(anaconda目录),找到Lib
,进入 - 找到
distutils
包,进入找到distutils.cfg
文件
用anaconda的话是这样的
[build]
compiler=mingw32
- 1
- 2
改为:
- 1
[build]
compiler=msvc
- 1
- 2
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.
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- ok!
这里是这个文件的地址,有需要的小伙伴可以自行下载
https://gist.github.com/cgpeter96/c56d28798faec5e689cf6139e8341d39
</div>
<link href="https://csdnimg.cn/release/phoenix/mdeditor/markdown_views-e44c3c0e64.css" rel="stylesheet">
</div>