COCO python API已安装,但可以';我不能进口它

COCO python API已安装,但可以';我不能进口它,python,python-2.7,pycocotools,Python,Python 2.7,Pycocotools,我正在使用Azure Databricks运行我的python代码。为此,我希望从COCO导入一个图像数据集;为此我安装了pycocotools API。但是当我试图导入库时,我得到一个错误,没有找到名为“pycocotools”的模块。我不知道我到底哪里做错了什么。这是我用来安装API的代码 %sh pip install "git+https://github.com/philferriere/cocoapi.git#egg=pycocotools&subdirectory=Pyth

我正在使用Azure Databricks运行我的python代码。为此,我希望从COCO导入一个图像数据集;为此我安装了pycocotools API。但是当我试图导入库时,我得到一个错误,没有找到名为“pycocotools”的模块。我不知道我到底哪里做错了什么。这是我用来安装API的代码

%sh
pip install "git+https://github.com/philferriere/cocoapi.git#egg=pycocotools&subdirectory=PythonAPI"
这是我得到的输出

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)
当我尝试导入库时

import pycocotools
这就是我得到的错误

ImportError: No module named 'pycocotools'

请帮我解决这个问题。

如果您在Conda工作,您可以按照以下步骤顺利安装、导入和使用此库

### 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
####在Conda命令提示符中输入以下内容###
#创造新环境
康达创建-n
#激活环境
康达激活
#安装cython
pip安装cython
#安装git
conda安装-c anaconda git
#从此GitHub rep安装Pycools
pip安装git+https://github.com/philferriere/cocoapi.git#egg=pycocotools^&子目录=PythonAPI
另外,我最近写了一整篇文章。一定要看一看