python-3.x - 云数据流 python3 作业未解决依赖关系
问题描述
我有一个简单的 apache 梁项目,使用 python 3 转换一些数据并写入大查询,它使用一个名为 texstat 的包,如果我在本地运行一切正常,但是当我在数据流上运行时,我收到以下错误:
NameError: name 'textstat' is not defined [while running 'generatedPtransform-441']
这是我当前的 setup.py 文件:
import setuptools
REQUIRED_PACKAGES = ['textstat==0.5.6']
PACKAGE_NAME = 'my_package'
PACKAGE_VERSION = '0.0.1'
setuptools.setup(
name=PACKAGE_NAME,
version=PACKAGE_VERSION,
description='Example project',
install_requires=REQUIRED_PACKAGES,
packages=setuptools.find_packages(),
)
这是我的管道参数
pipeline_args = [
'--project={}'.format('etl-example'),
'--runner={}'.format('Dataflow'),
'--temp_location=gs://dataflowtemporal/',
'--setup_file=./setup.py',
]
我像这样运行它
pipeline_options = PipelineOptions(pipeline_args)
pipeline_options.view_as(StandardOptions).streaming = True
pipeline = beam.Pipeline(options=pipeline_options)
...
pipeline.run()
在运行作业之前,我还尝试在终端上运行它:
python setup.py sdist --formats=gztar
但我得到的 texstat 没有被找到的相同结果。我尝试的另一件事是没有 setup.py 并且只有参数
--requirements_file=./requirements.txt
但同样,没有找到 texstat
在这一点上,我不知道还能尝试什么。
解决方案
通常这是因为该库未在您的 DoFn 中本地导入。
或者,您可以尝试https://cloud.google.com/dataflow/docs/resources/faq中提到的 --save_main_session 选项
推荐阅读
- python - 列表的乘积函数
- typescript - Typescript 在返回类型中引用自己的类型方法
- npm - npm 标志 --no-optional 仍在下载可选依赖项
- python - 给定一个整数数组,返回两个数字的索引
- java - Azure Functions 和临时文件存储
- python - 在 django 项目启动时定义变量
- spring - Spring Jackson ObjectMapper 在单元测试通过时无法进行 JSON 反序列化
- node.js - 使用 Sharp 获取调整后图像的精确尺寸
- javascript - Javascript:编写函数和条件检查的干净和优化方式的最佳实践
- cypress - 第二次启动cypress测试,url登陆错误页面