2

I'm using Azure Databricks to run my python code. For that I want an image dataset from COCO to be imported; for which I have installed pycocotools API. But when I'm trying to import the library I am getting an error 'No module named "pycocotools" is found. I'm not able to figure out where exactly I'm doing something wrong. This is the code what I have used to install the API

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

This is the output I got

DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
Requirement already satisfied: pycocotools from git+https://github.com/philferriere/cocoapi.git#egg=pycocotools&subdirectory=PythonAPI in /usr/local/lib/python2.7/dist-packages (2.0)

When I'm trying to import the library,

import pycocotools

This is what am getting as error.

ImportError: No module named 'pycocotools'

Please help me with this.

Ven
  • 19,015
  • 2
  • 41
  • 61
Luiy_coder
  • 321
  • 2
  • 11

1 Answers1

0

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.

Viraf
  • 121
  • 3