0

This is my project structure :

└──myfolder
    └──myproject
        ├── __init__.py
        ├── tester.py
        ├── learners
        │   ├── __init__.py
        │   ├── bag_learner.py
        │   ├── dqn_learner.py
        │   ├── q_learner.py
        │   ├── q_learner.pyc
        │   ├── stock_dqn_learner.py
        │   ├── stock_q_base_learner.py
        │   └── stock_q_learner.py
        └── utility
            ├── __init__.py
            ├── analysis.py
            └── util.py

I usually run program by python tester.py at myproject directory.

Now I'm trying to run this program via gcp command. What I did was to move to myfolder directory and run program by gcloud ml-engine local train --module-name=myproject.tester --package-path=myproject. But it occured an error:

  File "myproject/learners/q_learner.py", line 6, in <module>
    from utility import *
ImportError: No module named utility

I thought that program couldn't recognize myproject directory as a PYTHONPATH. So I changed directory to myproject, and run program by gcloud ml-engine local train --module-name=tester --package-path=./. but it also occured an error:

/Users/Chois/.pyenv/versions/2.7.13/bin/python2: No module named tester

How can I deal with it?

Dan Cornilescu
  • 39,470
  • 12
  • 57
  • 97
user3595632
  • 5,380
  • 10
  • 55
  • 111

1 Answers1

1

Is it possible for your import to be something like:

import myproject.utility as utility

And then proceed along the path you were on which was to execute gcloud commands with myfolder as the working directory.

Nikhil Kothari
  • 5,215
  • 2
  • 22
  • 28