cocodataset / cocoapi

COCO API - Dataset @ http://cocodataset.org/
Other
6.07k stars 3.75k forks source link

Unable to make install cocoapi #295

Open romass12 opened 5 years ago

romass12 commented 5 years ago

Python Environment = 3.7 Pip = 19.1.1

I am getting error :

error: Setup script exited with Beginning with Matplotlib 3.1, Python 3.6 or above is required.

This may be due to an out of date pip.

Make sure you have pip >= 9.0.1.

Makefile:7: recipe for target 'install' failed make: *** [install] Error 1

icmpnorequest commented 5 years ago

OS:Ubuntu 18.04 LTS Python Environment = 3.6.8 (System default version)

I followed the link https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/installation.md#coco-api-installation to install cocoapi. However, it shows the error below:

ubuntu:~/cocoapi-master/PythonAPI$ make
python setup.py build_ext --inplace
Traceback (most recent call last):
  File "setup.py", line 2, in <module>
    import numpy as np
ImportError: No module named numpy
Makefile:3: recipe for target 'all' failed
make: *** [all] Error 1

I have already installed the needed dependencies above. Of course Cython and Numpy. Could somebody help me fix this issue?

#####################################################################

Solution: https://stackoverflow.com/questions/56690223/ubuntu-18-04-lts-install-cocoapi

maxfiedler commented 5 years ago

I am facing a related issue. I am on an Ubuntu 18.04.2 Laptop in a virtualenv with Python 3.6.8

I also followed the link https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/installation.md#coco-api-installation to install cocoapi

but when running make in cocoapi/PythonAPI I get

x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/home/max/nomitri/code/tfod/.tfod/lib/python3.6/site-packages/numpy/core/include -I../common -I/usr/include/python3.6m -I/home/max/nomitri/code/tfod/.tfod/include/python3.6m -c pycocotools/_mask.c -o build/temp.linux-x86_64-3.6/pycocotools/_mask.o -Wno-cpp -Wno-unused-function -std=c99
pycocotools/_mask.c:4:10: fatal error: Python.h: No such file or directory
 #include "Python.h"
          ^~~~~~~~~~
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
Makefile:3: recipe for target 'all' failed
make: *** [all] Error 1

I have installed the dependencies as described in https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/installation.md

AzimAhmadzadeh commented 5 years ago

This seems to be an issue with python version. The original coco-api works well with python2, and not 3. Here, I copy my answer in stackoverflow:

Install

  1. Instead of the official version (which has issues with python 3) use an alternative one. Install it on your local machine, globally (i.e., outside any virtual environment). You can do this by:

    pip install git+https://github.com/philferriere/cocoapi.git#subdirectory=PythonAPI

  2. Check if it is installed globally:

    pip freeze | grep "pycocotools" You should see something like pycocotools==2.0.0 in your output.

  3. Now, inside your virtual-env (conda or whatever), first install numpy and cython using pip, and then:

    pip install pycocotools

Verify

Inside your project, import (for example) from pycocotools import mask as mask and then print(mask.__author__). This should print out the author's name, which is tsungyi.

Where Is It?

The installed package, like any other packages that are locally installed inside a virtual-env using pip, will go to External Libraries of your project, under site-packages. That means it is now part of your virtual-env and not part of your project. So, other users who may want to use your code, must repeat this installation on their virtual-env as well.


Environment: The above steps were tested on Ubuntu 18.4, python 3.6.8, pip 19.0.3.

chitraa commented 4 years ago

Hi, I just installed coco and pycocotools on a Windows 10 machine. Adding the requirements.txt file for the same (ideally pip should be able to download the dependencies, but since it's not doing that, here are the dependencies)

docopt
clint
tablib
coco
Cython
numpy
git+https://github.com/philferriere/cocoapi.git#subdirectory=PythonAPI
matplotlib
virafpatrawala commented 4 years ago

If you are working in Conda, you can follow the below steps to be able to install, import and use this library quite smoothly.

### Enter the below in your Conda Command Prompt ###
# Create a new environment
conda create -n <envName>
# Activate the environment
conda activate <envName>
# Install cython
pip install cython
# Install git
conda install -c anaconda git
# Install pycocotools from this GitHub rep
pip install git+https://github.com/philferriere/cocoapi.git#egg=pycocotools^&subdirectory=PythonAPI

Additionally, I have recently written an entire post on exploring and manipulating the COCO dataset. Do have a look.

MedAliMimouni commented 3 years ago

I'm using ubuntu 20.04 LTS, I'm using conda envirenment.

I tried the same solution

$pip install git+https://github.com/philferriere/cocoapi.git#egg=pycocotools^&subdirectory=PythonAPI

and I've got an error.

It is probably because you don't have gcc installed. so I run

$sudo apt install gcc

then it worked fine for me

Shane-Vimukthi commented 2 years ago

here's how i did successfully! (the reason is the gcc version) --- I am using Ubuntu

  1. install the dependencies: cython (pip install cython), opencv (pip install opencv-python)

  2. check the gcc version by this command: gcc --version

  3. your output will be like this 'Command 'gcc' not found, but can be installed with: sudo apt install gcc '

  4. Type the below commands to install the gcc: sudo apt update

    sudo apt install build-essential

    sudo apt-get install manpages-dev

  5. now check again the gcc version(step2) if you get below output

    'gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0 Copyright (C) 2019 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.'

  6. now run the code for pycocotools installations:

    pip install "git+https://github.com/philferriere/cocoapi.git#egg=pycocotools&subdirectory=PythonAPI"

  7. finally wait check if the installation is successful :

    'Successfully installed pycocotools-2.0'

beniben0 commented 2 years ago

I am facing a related issue. I am on an Ubuntu 18.04.2 Laptop in a virtualenv with Python 3.6.8

I also followed the link https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/installation.md#coco-api-installation to install cocoapi

but when running make in cocoapi/PythonAPI I get

x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/home/max/nomitri/code/tfod/.tfod/lib/python3.6/site-packages/numpy/core/include -I../common -I/usr/include/python3.6m -I/home/max/nomitri/code/tfod/.tfod/include/python3.6m -c pycocotools/_mask.c -o build/temp.linux-x86_64-3.6/pycocotools/_mask.o -Wno-cpp -Wno-unused-function -std=c99
pycocotools/_mask.c:4:10: fatal error: Python.h: No such file or directory
 #include "Python.h"
          ^~~~~~~~~~
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
Makefile:3: recipe for target 'all' failed
make: *** [all] Error 1

I have installed the dependencies as described in https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/installation.md

Hi! I have the same problem as you. How did you solve it? Your last link doesn't work anymore :/ Thx