gcloud ml-engine python3.5 运行 上的 tkinter 导入错误
gcloud ml-engine with python3.5 tkinter import error on run
我正在尝试 运行 我的模型在 Google 云 ml-engine 上使用:
gcloud ml-engine jobs submit training $NAME --module-name train.task_w2v \
--package-path train --runtime-version 1.8 --python-version 3.5 \
--scale-tier BASIC --staging-bucket $BUCKET --region $REGION
这是我的 setup.py:
from setuptools import find_packages
from setuptools import setup
REQUIRED_PACKAGES = ['numpy', 'tensorflow', 'pandas', 'matplotlib',
'opencv-python', 'PyYAML', 'coloredlogs', 'scikit-learn', 'scipy', 'matplotlib']
setup(
name='ConvMultiAttention',
version='0.9',
author='name',
install_requires=REQUIRED_PACKAGES,
packages=find_packages(),
include_package_data=True,
)
模型 运行 在本地运行良好并成功构建:
I master-replica-0 Successfully installed model-0.9 coloredlogs-10.0 cycler-0.10.0 humanfriendly-4.15.1 kiwisolver-1.0.1 matplotlib-2.2.2 opencv-python-3.4.1.15 pyparsing-2.2.0 master-replica-0
I master-replica-0 Running command: python3 -m train.task_w2v master-replica-0
但随后出现此异常:
master-replica-0 Traceback (most recent call last): File "/usr/lib/python3.5/tkinter/__init__.py", line 36, in import _tkinter ImportError: No module named '_tkinter'
master-replica-0 Command '['python3', '-m', 'train.task_w2v']' returned non-zero exit status 1
因为我的理解是 tkinter 是 python3.5 的一部分,所以我真的不知道这里出了什么问题,或者该怎么做。我尝试 运行 它没有 matplotlib 和较低的 tf 版本,但问题仍然存在。
我也收到这些警告:
google-cloud-spanner 0.29.0 has requirement requests<3.0dev,>=2.18.4, but you'll have requests 2.13.0 which is incompatible.
The script humanfriendly is installed in '/root/.local/bin' which is not on PATH.
我真的不知道如何处理,或者如果我需要的话。
在无头训练工作中使用 TK 不会非常有益。正如 user2368505 在评论中指出的那样,以下内容应避免使用 TK:
import matplotlib
matplotlib.use("agg")
为了对后代有益,我发现在我自己的本地 Ubuntu 虚拟机上,没有安装 tkinter。如果需要,可以将以下内容添加到您的 `setup.py:
import subprocess
subprocess.check_call(['apt-get', '-y', 'install', 'python3-tk'])
同样,不是直接有用,而是用来展示如何通过 setup.py
任意安装依赖项。
我正在尝试 运行 我的模型在 Google 云 ml-engine 上使用:
gcloud ml-engine jobs submit training $NAME --module-name train.task_w2v \
--package-path train --runtime-version 1.8 --python-version 3.5 \
--scale-tier BASIC --staging-bucket $BUCKET --region $REGION
这是我的 setup.py:
from setuptools import find_packages
from setuptools import setup
REQUIRED_PACKAGES = ['numpy', 'tensorflow', 'pandas', 'matplotlib',
'opencv-python', 'PyYAML', 'coloredlogs', 'scikit-learn', 'scipy', 'matplotlib']
setup(
name='ConvMultiAttention',
version='0.9',
author='name',
install_requires=REQUIRED_PACKAGES,
packages=find_packages(),
include_package_data=True,
)
模型 运行 在本地运行良好并成功构建:
I master-replica-0 Successfully installed model-0.9 coloredlogs-10.0 cycler-0.10.0 humanfriendly-4.15.1 kiwisolver-1.0.1 matplotlib-2.2.2 opencv-python-3.4.1.15 pyparsing-2.2.0 master-replica-0
I master-replica-0 Running command: python3 -m train.task_w2v master-replica-0
但随后出现此异常:
master-replica-0 Traceback (most recent call last): File "/usr/lib/python3.5/tkinter/__init__.py", line 36, in import _tkinter ImportError: No module named '_tkinter'
master-replica-0 Command '['python3', '-m', 'train.task_w2v']' returned non-zero exit status 1
因为我的理解是 tkinter 是 python3.5 的一部分,所以我真的不知道这里出了什么问题,或者该怎么做。我尝试 运行 它没有 matplotlib 和较低的 tf 版本,但问题仍然存在。
我也收到这些警告:
google-cloud-spanner 0.29.0 has requirement requests<3.0dev,>=2.18.4, but you'll have requests 2.13.0 which is incompatible.
The script humanfriendly is installed in '/root/.local/bin' which is not on PATH.
我真的不知道如何处理,或者如果我需要的话。
在无头训练工作中使用 TK 不会非常有益。正如 user2368505 在评论中指出的那样,以下内容应避免使用 TK:
import matplotlib
matplotlib.use("agg")
为了对后代有益,我发现在我自己的本地 Ubuntu 虚拟机上,没有安装 tkinter。如果需要,可以将以下内容添加到您的 `setup.py:
import subprocess
subprocess.check_call(['apt-get', '-y', 'install', 'python3-tk'])
同样,不是直接有用,而是用来展示如何通过 setup.py
任意安装依赖项。