代码之家  ›  专栏  ›  技术社区  ›  Krishnendu S. Kar

导入错误matplotlib。pyplot图

  •  1
  • Krishnendu S. Kar  · 技术社区  · 7 年前

    我正在通过云虚拟机实例使用云机器学习引擎开发对象检测器。遵循教程( https://cloud.google.com/blog/big-data/2017/06/training-an-object-detector-using-cloud-machine-learning-engine ).

    gcloud ml-engine jobs submit training `whoami`_object_detection_`date +%s` \
        --job-dir=${YOUR_GCS_BUCKET}/train \
        --packages dist/object_detection-0.1.tar.gz,slim/dist/slim-0.1.tar.gz \
        --module-name object_detection.train \
        --region us-central1 \
        --config object_detection/samples/cloud/cloud.yml \
        -- \
        --train_dir=${YOUR_GCS_BUCKET}/train \
        --pipeline_config_path=${YOUR_GCS_BUCKET}/data/faster_rcnn_resnet101_coco.config
    

    错误如下:

    ...object_detection/utils/visualization_utils.py", line 24, in <module>
    import matplotlib.pyplot as plt
    ImportError: No module named matplotlib.pyplot
    

    我已经使用pip安装了matplotlib。 这段代码可以很好地使用python2.7-c的import matplotlib。pyplot作为plt’。

    请帮忙。。 提前谢谢。

    1 回复  |  直到 7 年前
        1
  •  4
  •   Krishnendu S. Kar    7 年前

    通过在设置中添加包依赖项,可以解决此问题。py文件。

    from setuptools import find_packages
    from setuptools import setup
    
    REQUIRED_PACKAGES = ['Pillow>=1.0','matplotlib', ]
    
    setup(
        name='trainer',
        version='0.1',
        install_requires=REQUIRED_PACKAGES,
        packages=find_packages(),
        include_package_data=True,
        description='My trainer application package.'
    )