没有名为培训师的模块 [英] No module named trainer
问题描述
我有一个非常简单的教练,遵循示例目录结构:
I have a very simple trainer that follows the sample directory structure:
/dist
__init__.py
setup.py
/trainer
__init__.py
task.py
在/dist目录下,在本地运行良好:
Under the /dist directory, runs fine locally:
$ gcloud ml-engine local train
--package-path=trainer
--module-name=trainer.task
现在,在尝试将其部署到/dist目录和以下命令时:
Now, when trying to deploy it, under the /dist directory and this command:
$ gcloud ml-engine jobs submit training testA
--package-path=trainer
--module-name=trainer.task
--staging-bucket=$JOB_DIR
--region us-central1
它给我一个错误没有模块名称训练师"
It gives me an error "No moduled name trainer"
INFO 2017-04-13 12:28:35 -0700 master-replica-0 Installing collected packages: pyyaml, scipy, scikit-learn, trainer
INFO 2017-04-13 12:28:38 -0700 master-replica-0 Successfully installed pyyaml-3.12 scikit-learn-0.18.1 scipy-0.18.1 trainer-0.1
INFO 2017-04-13 12:28:38 -0700 master-replica-0 Running command: python -m trainer.task
ERROR 2017-04-13 12:28:38 -0700 master-replica-0 /usr/bin/python: No module named trainer
这是setup.py
here is the content of setup.py
from setuptools import find_packages
from setuptools import setup
REQUIRED_PACKAGES = [
'pyyaml',
'scipy==0.18.1',
'scikit-learn'
]
setup(
name='trainer',
version='0.1',
install_requires=REQUIRED_PACKAGES,
include_package_data=True,
description='Classifier test'
)
我在做什么错了?
谢谢
M
推荐答案
您在setup.py中缺少重要的一行,这是setup
函数调用的packages
自变量(参见
You are missing an important line in your setup.py, the packages
argument to the setup
function invocation (cf these instructions). Try this:
from setuptools import find_packages
from setuptools import setup
REQUIRED_PACKAGES = ['pyyaml','scipy==0.18.1','scikit-learn']
setup(
name='trainer',
version='0.1',
install_requires=REQUIRED_PACKAGES,
packages=find_packages(),
include_package_data=True,
description='Classifier test'
)
我已经更新了CloudML引擎文档(可能需要几天的时间传播).
I've updated the CloudML Engine docs (may take a few days to propagate).
我使用--package-path=trainer
复制了您的命令,并进行了上述更改,一切都在云中正常运行.
I replicated your command using --package-path=trainer
and the above changes, and things run properly in the cloud.
最后,尽管它无害,但dist/
中的__init__.py
是不必要的,可以安全地删除.
Finally, although it is harmless, the __init__.py
in dist/
is unnecessary and can safely be removed.
这篇关于没有名为培训师的模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!