我正在使用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'
请帮助我。
答案 0 :(得分:0)
如果您在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
此外,我最近在exploring and manipulating the COCO dataset上写了整篇文章。看看。