win10 installation pycocotools record

foreword

        Since the neural network needs to run the coco dataset, install pycocotools on the computer. After testing, the direct pip or conda installation in the win10 system will fail. This article records the process of solving this problem.

Plan 1 (Edited on 2021.11.26)

Option 1 is much easier than Option 2.

1. Download files

        Enter the Tsinghua mirror website , and download the .whl file according to the python version.

2. Install pycocotools-windows

        Win+r, enter the cmd interface, activate the virtual environment you want to install, and cd to the directory where the file downloaded in the first step is located.

#e.g
pip install  pycocotools_windows-2.0-cp37-cp37m-win_amd64.whl

Plan Two (edited on November 25, 2021)

1. Environmental preparation

1. Install Microsoft C++

        The c++ file needs to be compiled later, here I installed Visual Studio directly . It feels like overkill, there should be an easy way, but at least the problem is solved.

2. Download the source code

In any folder, shift+right click to open the power shell, and enter the following code:

git clone  https://github.com/pdollar/coco.git 




#如果git不下来,可以执行下面这个指令,不翻墙也很快:
git clone  https://github.com.cnpmjs.org/pdollar/coco.git 

2. Installation

1. Enter the file. win+R to enter the cmd interface.

cd xxx/coco/PythonAPI   #xxx为前面克隆文件coco的存放路径

2. Change the file. Delete the two parameters '-Wno-cpp' and '-Wno-unused-function' in line 12 of setup.py under the PythonAPI folder, as shown in the yellow part in the figure below. save document.

3. Compile the file.

conda activate yourenv  #有numpy即可
python setup.py build_ext install

 4. Import environment

        The last and most important step is to copy the pycocotools folder in PythonAPI to your own python environment.        

        For example: copy to the C:\Users\xxx\miniconda3\envs\RL_env\Lib\site-packages folder.

Summarize

        I tried many ways to install pycocotools under win10, and finally solved it according to the above method. I hope it will be helpful to everyone.

reference article

1. Windows10 installation pycocotools error reporting solution_Flying pig's blog-CSDN blog_pycocotools installation error reporting

2. Install pycocotools on Windows

Guess you like

Origin blog.csdn.net/qq_40691868/article/details/121524706