【问题标题】:import error matplotlib.pyplot导入错误 matplotlib.pyplot
【发布时间】:2017-11-12 13:06:19
【问题描述】:

我正在通过 Cloud-VM 实例使用 Cloud Machine Learning Engine 开发对象检测器。按照教程 (https://cloud.google.com/blog/big-data/2017/06/training-an-object-detector-using-cloud-machine-learning-engine)。

当我在下面提交训练作业时,我在 Google Cloud Platform 上遇到模块导入错误:

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 install 安装了 matplotlib。 此代码运行良好 python2.7 -c 'import matplotlib.pyplot as plt'。

请帮忙.. 提前致谢。

【问题讨论】:

  • 其他人和你有同样的问题,我想链接到你的答案,但在你回答自己的问题之前我不能。您可以将答案复制为真实答案吗?然后在那之后,将你的新问题移到它自己的问题上?为此,查看更多日志会很有帮助。
  • 对这些东西完全陌生。你能帮我一步一步地告诉我你要我做什么吗?
  • 没问题。看来您添加了一个新问题,这是正确的做法——我在那里回答了。您还添加了相同的问题作为下面的答案。让我们继续删除它,因为它不是真正的答案(答案末尾应该有一个链接要删除)。另外,请编辑问题本身以从“但是,即使在解决此问题之后”和之后删除。最后两个步骤:将有关“此问题已解决”的文章移至其自己的答案,并将其从问题本身中删除。有意义吗?
  • 很有意义:)

标签: google-cloud-platform google-cloud-ml


【解决方案1】:

通过在 setup.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.'
)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-10-28
    • 2015-03-04
    • 2015-04-06
    • 1970-01-01
    • 2014-12-05
    • 2017-11-03
    • 2013-07-03
    相关资源
    最近更新 更多