[fix] pycocotools can not build with py>3.8 and no VS14 for compilation in windows
Thanks for your contribution and we appreciate it a lot. The following instructions would make your pull request more healthy and more easily get feedback. If you do not understand some items, don't worry, just make the pull request and seek help from maintainers.
Motivation
Using python 3.8 in Windows and pycocotools cannot be installed. So change to this one.
Modification
add platform check.
BC-breaking (Optional)
Does the modification introduce changes that break the backward-compatibility of the downstream repos? If so, please describe how it breaks the compatibility and how the downstream projects should modify their code to keep compatibility with this PR. no
Use cases (Optional)
If this PR introduces a new feature, it is better to list some use cases here, and update the documentation. pip install mdmet
Checklist
- Pre-commit or other linting tools are used to fix the potential lint issues.
- The modification is covered by complete unit tests. If not, please add more unit test to ensure the correctness.
- If the modification has potential influence on downstream projects, this PR should be tested with downstream projects, like MMDet or MMCls.
- The documentation has been modified accordingly, like docstring or example tutorials.
error like this
(py38) PS C:\Users\Administrator> pip install mmdet==2.22.0 -i https://pypi.tuna.tsinghua.edu.cn/simple
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting mmdet==2.22.0
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/66/61/0e03c564c04d3d84a2d4f6e218c1fa287e61955322dcaa943f66ec4fbae9/mmdet-2.22.0-py3-none-any.whl (1.3 MB)
|████████████████████████████████| 1.3 MB 544 kB/s
Requirement already satisfied: six in c:\users\administrator\miniconda3\envs\py38\lib\site-packages (from mmdet==2.22.0) (1.16.0)
Collecting pycocotools
Using cached https://pypi.tuna.tsinghua.edu.cn/packages/75/5c/ac61ea715d7a89ecc31c090753bde28810238225ca8b71778dfe3e6a68bc/pycocotools-2.0.4.tar.gz (106 kB)
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing wheel metadata ... done
Requirement already satisfied: matplotlib in c:\users\administrator\miniconda3\envs\py38\lib\site-packages (from mmdet==2.22.0) (3.5.1)
Requirement already satisfied: numpy in c:\users\administrator\miniconda3\envs\py38\lib\site-packages (from mmdet==2.22.0) (1.22.3)
Requirement already satisfied: terminaltables in c:\users\administrator\miniconda3\envs\py38\lib\site-packages (from mmdet==2.22.0) (3.1.10)
Requirement already satisfied: kiwisolver>=1.0.1 in c:\users\administrator\miniconda3\envs\py38\lib\site-packages (from matplotlib->mmdet==2.22.0) (1.3.2)
Requirement already satisfied: pyparsing>=2.2.1 in c:\users\administrator\miniconda3\envs\py38\lib\site-packages (from matplotlib->mmdet==2.22.0) (3.0.7)
Requirement already satisfied: fonttools>=4.22.0 in c:\users\administrator\miniconda3\envs\py38\lib\site-packages (from matplotlib->mmdet==2.22.0) (4.30.0)
Requirement already satisfied: packaging>=20.0 in c:\users\administrator\miniconda3\envs\py38\lib\site-packages (from matplotlib->mmdet==2.22.0) (21.3)
Requirement already satisfied: cycler>=0.10 in c:\users\administrator\miniconda3\envs\py38\lib\site-packages (from matplotlib->mmdet==2.22.0) (0.11.0)
Requirement already satisfied: python-dateutil>=2.7 in c:\users\administrator\miniconda3\envs\py38\lib\site-packages (from matplotlib->mmdet==2.22.0) (2.8.2)
Requirement already satisfied: pillow>=6.2.0 in c:\users\administrator\miniconda3\envs\py38\lib\site-packages (from matplotlib->mmdet==2.22.0) (9.0.1)
Building wheels for collected packages: pycocotools
Building wheel for pycocotools (PEP 517) ... error
ERROR: Command errored out with exit status 1:
command: 'C:\Users\Administrator\miniconda3\envs\py38\python.exe' 'C:\Users\Administrator\miniconda3\envs\py38\lib\site-packages\pip\_vendor\pep517\in_process\_in_process.py' build_wheel 'C:\Users\ADMINI~1\AppData\Local\Temp\tmprgehj4jg'
cwd: C:\Users\Administrator\AppData\Local\Temp\pip-install-skr_hg80\pycocotools_9e584a053ba44d929b7530e67949486d
Complete output (14 lines):
running bdist_wheel
running build
running build_py
creating build
creating build\lib.win-amd64-3.8
creating build\lib.win-amd64-3.8\pycocotools
copying pycocotools\coco.py -> build\lib.win-amd64-3.8\pycocotools
copying pycocotools\cocoeval.py -> build\lib.win-amd64-3.8\pycocotools
copying pycocotools\mask.py -> build\lib.win-amd64-3.8\pycocotools
copying pycocotools\__init__.py -> build\lib.win-amd64-3.8\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: Failed building wheel for pycocotools
Failed to build pycocotools
ERROR: Could not build wheels for pycocotools which use PEP 517 and cannot be installed directly
Hi @EasonQYS , Thanks for your kind PR. Previously it uses pycocotools-windows, but it is later changed to pycocotools, could you leave a comment in the file to indicate why it is necessary? This will serve as a reminder for following developers to not change it again.
There is no issue with current requirements, pycocotools can be installed on windows without any issues.
The reason for error is obvious, @EasonQYS you have to install VS14 for compilation:
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/
maybe this will be better:
pycocotools; platform_system == "Linux"
# we have a easy way to deal with python<=3.8
pycocotools-windows; platform_system == "Windows" and python_version <= '3.8'
# if python>3.8, you have to install Visual C++ 14.0 or greater from "https://visualstudio.microsoft.com/visual-cpp-build-tools" first. Then you can build pycocotools in your computer.
pycocotools; platform_system == "Windows" and python_version > '3.8'
Codecov Report
Patch coverage is 97.56% of modified lines.
| Files Changed | Coverage |
|---|---|
| mmdet/models/dense_heads/ssd_head.py | ø |
| mmdet/models/necks/fpn.py | ø |
| mmdet/models/detectors/yolox.py | 50.00% |
| mmdet/datasets/api_wrappers/panoptic_evaluation.py | 100.00% |
| mmdet/datasets/coco_panoptic.py | 100.00% |
| mmdet/datasets/custom.py | 100.00% |
| mmdet/datasets/pipelines/loading.py | 100.00% |
| mmdet/datasets/pipelines/transforms.py | 100.00% |
| mmdet/models/dense_heads/centripetal_head.py | 100.00% |
| mmdet/models/dense_heads/corner_head.py | 100.00% |
| ... and 3 more |
:loudspeaker: Thoughts on this report? Let us know!.
Hi @EasonQYS , Since we have rebased dev, could you also rebase this branch and fix the lint issue?