1
votes

I’m working on an object detector using Cloud Machine Learning Engine via a Cloud-VM instance. Following the tutorial (https://cloud.google.com/blog/big-data/2017/06/training-an-object-detector-using-cloud-machine-learning-engine).

I get a module import error on Google Cloud Platform when I submit the training job below:

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

The error is below:

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

I've installed matplotlib using pip install. This code works fine python2.7 -c 'import matplotlib.pyplot as plt'.

Please help.. Thanks in advance.

1
Others have the same question as you and I want to link to your answer, but I can't until you've answered your own question. Can you copy the answer as a true answer? And then after that, move your new question to it's own question? For that, it will be helpful to see more of your logs. - rhaertel80
Absolutely new to these things.. Can u please help me step by step of what you're asking me to do? - Krishnendu S. Kar
no problem. It appears you added a new question, which is the right thing to do -- I answered there. You also added the same question as an answer below. Let's go ahead and delete that, since it's not really an answer (there should be a link at the end of the answer to delete). Also, please edit the question itself to remove from "But, even after resolving this" and after. Final two steps: Move the piece about "This issue is resolved" to it's own answer and delete it from the question itself. Make sense? - rhaertel80
makes perfect sense :) - Krishnendu S. Kar

1 Answers

4
votes

This issue is resolved by adding package dependencies in the setup.py file.

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.'
)