【发布时间】:2017-12-12 05:21:25
【问题描述】:
我按照tutorial 向 Google ML 引擎提交机器学习作业。然后我遇到了错误 ImportError: No module named matplotlib.pyplot,但通过将 Matplotlib 添加到 setup.py 中的 RequiredPackages 来解决它。然后我面临另一个错误是 ImportError: No module named _tkinter, please install the python-tk package。我找到了这个solution 和这个solution,但没有帮助并给我另一个错误。
我的包的构建轮子失败
Command "/usr/bin/python -u -c "import setuptools, tokenize;file='/tmp/pip-T6kjZl-build/setup.py';f=getattr(tokenize , 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile (code, file, 'exec'))" install --record /tmp/pip-4LpzWh-record/install-record.txt --single-version-externally-managed --compile --用户 --prefix=" 失败,错误代码 1 在 /tmp/pip-T6kjZl-build/
命令'['pip', 'install', '--user', '--upgrade', '--force-reinstall', '--no-deps', u'my-package-0.1。 1.tar.gz']' 返回非零退出状态 1
我的 setup.py。
"""Setup script for object_detection."""
import logging
import subprocess
from setuptools import find_packages
from setuptools import setup
from setuptools.command.install import install
class CustomCommands(install):
def RunCustomCommand(self, command_list):
p = subprocess.Popen(
command_list,
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
# Can use communicate(input='y\n'.encode()) if the command run requires
# some confirmation.
stdout_data, _ = p.communicate()
logging.info('Log command output: %s', stdout_data)
if p.returncode != 0:
raise RuntimeError('Command %s failed: exit code: %s', (command_list, p.returncode))
def run(self):
self.RunCustomCommand(['apt-get', 'update'])
self.RunCustomCommand(
['apt-get', 'install', '-y', 'python-tk'])
install.run(self)
REQUIRED_PACKAGES = ['Pillow>=1.0', 'Matplotlib>=2.1']
setup(
name='object_detection',
version='0.1',
install_requires=REQUIRED_PACKAGES,
include_package_data=True,
packages=[p for p in find_packages() if
p.startswith('object_detection')],
description='Tensorflow Object Detection Library',
cmdclass={
'install': CustomCommands,
})
【问题讨论】:
-
您介意复制完整的 setup.py 并可能提供更多日志吗?
-
我添加了
setup.py。其实我已经把所有的日志都贴出来了。 -
我复制了你的 setup.py 并做了一个小改动:我设置了 package=find_packages()。然后我创建了一个简单的 main.py: import matplotlib.pyplot import _tkinter print "Hello, world!"提交了作业,并且成功了。
gcloud ml-engine jobs submit training matplotlib --package-path=a --module-name="a.main" --staging-bucket=gs://my-bucket -
我尝试浏览博文。很多小错误,我会提交补丁。我尝试逐字使用您的 setup.py 文件,它似乎有效,也就是说,我没有收到与您看到的相同的错误。也就是说,我仍然收到有关缺少方法的错误。我也会尝试修复和修补它。
-
它正在与 --runtime-version=1.2 一起使用!