我正在尝试在Windows 10上使用pycocotools
加载PyCharm
(from here)程序包。
起初我遇到以下错误:
Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools":
因此,我安装了Visual Studio 2019
并启用了C ++软件包。看起来它解决了错误,但是现在我又有了一个,这对我来说很神秘:
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\VC\\Tools\\MSVC\\14.21.27702\\bin\\HostX86\\x64\\cl.exe' failed with exit status 2
这是完整的堆栈跟踪:
Collecting pycocotools
Using cached https://files.pythonhosted.org/packages/96/84/9a07b1095fd8555ba3f3d519517c8743c2554a245f9476e5e39869f948d2/pycocotools-2.0.0.tar.gz
Building wheels for collected packages: pycocotools
Running setup.py bdist_wheel for pycocotools: started
Running setup.py bdist_wheel for pycocotools: finished with status 'error'
Complete output from command [PATH\TO\VENV\]\plugin\Scripts\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\[USER]\\AppData\\Local\\Temp\\pycharm-packaging\\pycocotools\\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\[USER]~1\AppData\Local\Temp\pip-wheel-u3vetp7m --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
warning: build_py: byte-compiling is disabled, skipping.
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\Release\common
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.21.27702\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -I[PATH\TO\VENV\]\plugin\lib\site-packages\numpy\core\include -Icommon -I[PATH\TO\VENV\]\plugin\include -IC:\Users\[USER]\AppData\Local\Programs\Python\Python36\include -IC:\Users\[USER]\AppData\Local\Programs\Python\Python36\include "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.21.27702\ATLMFC\include" "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.21.27702\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\cppwinrt" /Tcpycocotools/_mask.c /Fobuild\temp.win-amd64-3.6\Release\pycocotools/_mask.obj -Wno-cpp -Wno-unused-function -std=c99
cl : Command line error D8021 : invalid numeric argument '/Wno-cpp'
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\VC\\Tools\\MSVC\\14.21.27702\\bin\\HostX86\\x64\\cl.exe' failed with exit status 2
----------------------------------------
Running setup.py clean for pycocotools
Failed to build pycocotools
Installing collected packages: pycocotools
Running setup.py install for pycocotools: started
Running setup.py install for pycocotools: finished with status 'error'
Complete output from command [PATH\TO\VENV\]\plugin\Scripts\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\[USER]\\AppData\\Local\\Temp\\pycharm-packaging\\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\[USER]~1\AppData\Local\Temp\pip-record-9ez7fllv\install-record.txt --single-version-externally-managed --compile --install-headers [PATH\TO\VENV\]\plugin\include\site\python3.6\pycocotools:
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
warning: build_py: byte-compiling is disabled, skipping.
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\Release\common
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.21.27702\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -I[PATH\TO\VENV\]\plugin\lib\site-packages\numpy\core\include -Icommon -I[PATH\TO\VENV\]\plugin\include -IC:\Users\[USER]\AppData\Local\Programs\Python\Python36\include -IC:\Users\[USER]\AppData\Local\Programs\Python\Python36\include "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.21.27702\ATLMFC\include" "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.21.27702\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\cppwinrt" /Tcpycocotools/_mask.c /Fobuild\temp.win-amd64-3.6\Release\pycocotools/_mask.obj -Wno-cpp -Wno-unused-function -std=c99
cl : Command line error D8021 : invalid numeric argument '/Wno-cpp'
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\VC\\Tools\\MSVC\\14.21.27702\\bin\\HostX86\\x64\\cl.exe' failed with exit status 2
----------------------------------------
Failed building wheel for pycocotools
Command "[PATH\TO\VENV\]\plugin\Scripts\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\[USER]\\AppData\\Local\\Temp\\pycharm-packaging\\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\[USER]~1\AppData\Local\Temp\pip-record-9ez7fllv\install-record.txt --single-version-externally-managed --compile --install-headers [PATH\TO\VENV\]\plugin\include\site\python3.6\pycocotools" failed with error code 1 in C:\Users\[USER]\AppData\Local\Temp\pycharm-packaging\pycocotools\
You are using pip version 10.0.1, however version 19.1.1 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.
可能是什么问题,我该如何解决?
答案 0 :(得分:0)
可可维护者在Windows中不提供支持,请检查issue #9:
我们将不提供Windows支持。
但幸运的是,您可以在Windows上编译一个fork:https://github.com/philferriere/cocoapi
只需运行:pip3 install "git+https://github.com/philferriere/cocoapi.git#egg=pycocotools&subdirectory=PythonAPI"