[英]GCP : PYTHONPATH screwed up when run program by “gcloud ml-engine local train”
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. 我通常在
myproject
目录下通过python tester.py
运行程序。
Now I'm trying to run this program via gcp
command. 现在,我正在尝试通过
gcp
命令运行该程序。 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
. 我所做的是移动到
myfolder
目录并通过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
. 我以为该程序无法将
myproject
目录识别为PYTHONPATH
。 So I changed directory to myproject
, and run program by gcloud ml-engine local train --module-name=tester --package-path=./
. 因此我将目录更改为
myproject
,并通过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? 我该如何处理?
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. 然后继续执行您以myfolder作为工作目录执行gcloud命令的路径。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.