Cloud DataFlow 中的 Python 依赖项,requirements.txt 在本地工作,但在工作线程上不起作用

2023-12-12

我正在尝试使用requirements.txt 文件运行我的Cloud DataFlow 作业,如此处所述

https://cloud.google.com/dataflow/pipelines/dependency-python

我可以只构建 python 库,而不是从源代码构建所有 opencv(需要 20-30 分钟)

从我的计算引擎,我可以做到这一点

root@fcfca6a4dad2:/DeepMeerkat# pip install opencv-python
Collecting opencv-python
  Downloading opencv_python-3.2.0.7-cp27-cp27mu-manylinux1_x86_64.whl (6.7MB)
    100% |################################| 6.7MB 163kB/s
Collecting numpy>=1.11.1 (from opencv-python)
  Downloading numpy-1.13.0-cp27-cp27mu-manylinux1_x86_64.whl (16.6MB)
    100% |################################| 16.6MB 68kB/s
Installing collected packages: numpy, opencv-python
  Found existing installation: numpy 1.8.2
    DEPRECATION: Uninstalling a distutils installed project (numpy) has been deprecated and will be removed in a future version. This is due to the fact that uninstalling a distutils project will only partially uninstall the project.
    Uninstalling numpy-1.8.2:
      Successfully uninstalled numpy-1.8.2
Successfully installed numpy-1.13.0 opencv-python-3.2.0.7

我可以将其与其他一些模块一起包装到需求文件中

root@fcfca6a4dad2:/DeepMeerkat# pip install -r tests/prediction/requirements.txt
Requirement already satisfied: opencv-python in /usr/local/lib/python2.7/dist-packages (from -r tests/prediction/requirements.txt (line 1))
Collecting tensorflow==1.0.1 (from -r tests/prediction/requirements.txt (line 2))
  Downloading tensorflow-1.0.1-cp27-cp27mu-manylinux1_x86_64.whl (44.1MB)
    100% |################################| 44.1MB 27kB/s
Requirement already satisfied: numpy in /usr/local/lib/python2.7/dist-packages (from -r tests/prediction/requirements.txt (line 3))
Requirement already satisfied: mock>=2.0.0 in /usr/local/lib/python2.7/dist-packages (from tensorflow==1.0.1->-r tests/prediction/requirements.txt (line 2))
Requirement already satisfied: wheel in /usr/lib/python2.7/dist-packages (from tensorflow==1.0.1->-r tests/prediction/requirements.txt (line 2))
Requirement already satisfied: six>=1.10.0 in /usr/local/lib/python2.7/dist-packages (from tensorflow==1.0.1->-r tests/prediction/requirements.txt (line 2))
Requirement already satisfied: protobuf>=3.1.0 in /usr/local/lib/python2.7/dist-packages (from tensorflow==1.0.1->-r tests/prediction/requirements.txt (line 2))
Requirement already satisfied: funcsigs>=1; python_version < "3.3" in /usr/local/lib/python2.7/dist-packages (from mock>=2.0.0->tensorflow==1.0.1->-r tests/prediction/requirements.txt (line 2))
Requirement already satisfied: pbr>=0.11 in /usr/local/lib/python2.7/dist-packages (from mock>=2.0.0->tensorflow==1.0.1->-r tests/prediction/requirements.txt (line 2))
Requirement already satisfied: setuptools in /usr/local/lib/python2.7/dist-packages (from protobuf>=3.1.0->tensorflow==1.0.1->-r tests/prediction/requirements.txt (line 2))
Installing collected packages: tensorflow
Successfully installed tensorflow-1.0.1

但是,当我将其发送到云数据流时,它无法从工作人员中找到 opencv-python 。

root@fcfca6a4dad2:/DeepMeerkat# python tests/prediction/run.py \
>     --runner DataflowRunner \
>     --project $PROJECT \
>     --staging_location $BUCKET/staging \
>     --temp_location $BUCKET/temp \
>     --job_name $PROJECT-deepmeerkat \
>     --setup_file tests/prediction/setup.py \
>     --requirements_file tests/prediction/requirements.txt
No handlers could be found for logger "oauth2client.contrib.multistore_file"
/usr/local/lib/python2.7/dist-packages/apache_beam/io/gcp/gcsio.py:113: DeprecationWarning: object() takes no parameters
  super(GcsIO, cls).__new__(cls, storage_client))
INFO:root:Starting the size estimation of the input
INFO:oauth2client.transport:Attempting refresh to obtain initial access_token
INFO:root:Finished the size estimation of the input at 1 files. Estimation took 0.0855119228363 seconds
INFO:root:Starting the size estimation of the input
INFO:oauth2client.transport:Attempting refresh to obtain initial access_token
INFO:root:Finished the size estimation of the input at 1 files. Estimation took 0.0597159862518 seconds
/usr/local/lib/python2.7/dist-packages/apache_beam/coders/typecoders.py:135: UserWarning: Using fallback coder for typehint: Any.
  warnings.warn('Using fallback coder for typehint: %r.' % typehint)
INFO:root:Starting GCS upload to gs://api-project-773889352370-testing/staging/api-project-773889352370-deepmeerkat.1499372970.163850/requirements.txt...
INFO:oauth2client.transport:Attempting refresh to obtain initial access_token
INFO:root:Completed GCS upload to gs://api-project-773889352370-testing/staging/api-project-773889352370-deepmeerkat.1499372970.163850/requirements.txt
INFO:root:Executing command: ['/usr/bin/python', '-m', 'pip', 'install', '--download', '/tmp/dataflow-requirements-cache', '-r', 'tests/prediction/requirements.txt', '--no-binary', ':all:']
DEPRECATION: pip install --download has been deprecated and will be removed in the future. Pip now has a download command that should be used instead.
Collecting opencv-python (from -r tests/prediction/requirements.txt (line 1))
  Could not find a version that satisfies the requirement opencv-python (from -r tests/prediction/requirements.txt (line 1)) (from versions: )
No matching distribution found for opencv-python (from -r tests/prediction/requirements.txt (line 1))
Traceback (most recent call last):
  File "tests/prediction/run.py", line 22, in <module>
    predict.run()
  File "/DeepMeerkat/tests/prediction/modules/predict.py", line 32, in run
    p.run()
  File "/usr/local/lib/python2.7/dist-packages/apache_beam/pipeline.py", line 167, in run
    self.to_runner_api(), self.runner, self._options).run(False)
  File "/usr/local/lib/python2.7/dist-packages/apache_beam/pipeline.py", line 176, in run
    return self.runner.run(self)
  File "/usr/local/lib/python2.7/dist-packages/apache_beam/runners/dataflow/dataflow_runner.py", line 252, in run
    self.dataflow_client.create_job(self.job), self)
  File "/usr/local/lib/python2.7/dist-packages/apache_beam/utils/retry.py", line 168, in wrapper
    return fun(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/apache_beam/runners/dataflow/internal/apiclient.py", line 425, in create_job
    self.create_job_description(job)
  File "/usr/local/lib/python2.7/dist-packages/apache_beam/runners/dataflow/internal/apiclient.py", line 448, in create_job_description
    job.options, file_copy=self._gcs_file_copy)
  File "/usr/local/lib/python2.7/dist-packages/apache_beam/runners/dataflow/internal/dependency.py", line 307, in stage_job_resources
    setup_options.requirements_file, requirements_cache_path)
  File "/usr/local/lib/python2.7/dist-packages/apache_beam/runners/dataflow/internal/dependency.py", line 241, in _populate_requirements_cache
    processes.check_call(cmd_args)
  File "/usr/local/lib/python2.7/dist-packages/apache_beam/utils/processes.py", line 44, in check_call
    return subprocess.check_call(*args, **kwargs)
  File "/usr/lib/python2.7/subprocess.py", line 540, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['/usr/bin/python', '-m', 'pip', 'install', '--download', '/tmp/dataflow-requirements-cache', '-r', 'tests/prediction/requirements.txt', '--no-binary', ':all:']' returned non-zero exit status 1

问题似乎出在“无二进制标志”上。本地运行(卸载上述之后)

root@fcfca6a4dad2:/DeepMeerkat# pip install -r tests/prediction/requirements.txt --no-binary :all:
Collecting opencv-python (from -r tests/prediction/requirements.txt (line 1))
  Could not find a version that satisfies the requirement opencv-python (from -r tests/prediction/requirements.txt (line 1)) (from versions: )
No matching distribution found for opencv-python (from -r tests/prediction/requirements.txt (line 1))

无二进制标志被描述为排除损坏的轮子?这在本例中如何适用?

可以确认模块可以运行

again,

root@fcfca6a4dad2:/DeepMeerkat# pip install opencv-python
Collecting opencv-python
  Using cached opencv_python-3.2.0.7-cp27-cp27mu-manylinux1_x86_64.whl
Requirement already satisfied: numpy>=1.11.1 in /usr/local/lib/python2.7/dist-packages (from opencv-python)
Installing collected packages: opencv-python
Successfully installed opencv-python-3.2.0.7
root@fcfca6a4dad2:/DeepMeerkat# python
Python 2.7.9 (default, Jun 29 2016, 13:08:31)
[GCC 4.9.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
>>>

我认为您看到的错误实际上是由于工作人员未能安装轮文件而引起的。如上所述opencv-python 包页面轮文件的问题可能会导致包显示为未找到。

在这种情况下,您可以使用 PyPI 中没有的包的说明并指定--extra_package <local path to wheel file>而不是添加 opencv-python 作为要求。这应该会导致轮文件被暂存并安装在每个工作人员中。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Cloud DataFlow 中的 Python 依赖项,requirements.txt 在本地工作,但在工作线程上不起作用 的相关文章

  • 通过 Scrapy 抓取 Google Analytics

    我一直在尝试使用 Scrapy 从 Google Analytics 获取一些数据 尽管我是一个完全的 Python 新手 但我已经取得了一些进展 我现在可以通过 Scrapy 登录 Google Analytics 但我需要发出 AJAX
  • SQLAlchemy 通过关联对象声明式多对多自连接

    我有一个用户表和一个朋友表 它将用户映射到其他用户 因为每个用户可以有很多朋友 这个关系显然是对称的 如果用户A是用户B的朋友 那么用户B也是用户A的朋友 我只存储这个关系一次 除了两个用户 ID 之外 Friends 表还有其他字段 因此
  • 将 saxon 与 python 结合使用

    我需要使用 python 处理 XSLT 目前我正在使用仅支持 XSLT 1 的 lxml 现在我需要处理 XSLT 2 有没有办法将 saxon XSLT 处理器与 python 一起使用 有两种可能的方法 设置一个 HTTP 服务 接受
  • 将数据从 python pandas 数据框导出或写入 MS Access 表

    我正在尝试将数据从 python pandas 数据框导出到现有的 MS Access 表 我想用已更新的数据替换 MS Access 表 在 python 中 我尝试使用 pandas to sql 但收到错误消息 我觉得很奇怪 使用 p
  • 将 Matplotlib 误差线放置在不位于条形中心的位置

    我正在 Matplotlib 中生成带有错误栏的堆积条形图 不幸的是 某些层相对较小且数据多样 因此多个层的错误条可能重叠 从而使它们难以或无法读取 Example 有没有办法设置每个误差条的位置 即沿 x 轴移动它 以便重叠的线显示在彼此
  • Django:按钮链接

    我是一名 Django 新手用户 尝试创建一个按钮 单击该按钮会链接到我网站中的另一个页面 我尝试了一些不同的例子 但似乎没有一个对我有用 举个例子 为什么这不起作用
  • 从字符串中删除识别的日期

    作为输入 我有几个包含不同格式日期的字符串 例如 彼得在16 45 我的生日是1990年7月8日 On 7 月 11 日星期六我会回家 I use dateutil parser parse识别字符串中的日期 在下一步中 我想从字符串中删除
  • Python 函数可以从作用域之外赋予新属性吗?

    我不知道你可以这样做 def tom print tom s locals locals def dick z print z name z name z guest Harry print z guest z guest print di
  • 如何加速Python中的N维区间树?

    考虑以下问题 给定一组n间隔和一组m浮点数 对于每个浮点数 确定包含该浮点数的区间子集 这个问题已经通过构建一个解决区间树 https en wikipedia org wiki Interval tree 或称为范围树或线段树 已经针对一
  • 如何在ipywidget按钮中显示全文?

    我正在创建一个ipywidget带有一些文本的按钮 但按钮中未显示全文 我使用的代码如下 import ipywidgets as widgets from IPython display import display button wid
  • IO 密集型任务中的 Python 多线程

    建议仅在 IO 密集型任务中使用 Python 多线程 因为 Python 有一个全局解释器锁 GIL 只允许一个线程持有 Python 解释器的控制权 然而 多线程对于 IO 密集型操作有意义吗 https stackoverflow c
  • 如何在Python中对类别进行加权随机抽样

    给定一个元组列表 其中每个元组都包含一个概率和一个项目 我想根据其概率对项目进行采样 例如 给出列表 3 a 4 b 3 c 我想在 40 的时间内对 b 进行采样 在 python 中执行此操作的规范方法是什么 我查看了 random 模
  • 如何在seaborn displot中使用hist_kws

    我想在同一图中用不同的颜色绘制直方图和 kde 线 我想为直方图设置绿色 为 kde 线设置蓝色 我设法弄清楚使用 line kws 来更改 kde 线条颜色 但 hist kws 不适用于显示 我尝试过使用 histplot 但我无法为
  • 对年龄列进行分组/分类

    我有一个数据框说df有一个柱子 Ages gt gt gt df Age 0 22 1 38 2 26 3 35 4 35 5 1 6 54 我想对这个年龄段进行分组并创建一个像这样的新专栏 If age gt 0 age lt 2 the
  • 如何在 Python 中追加到 JSON 文件?

    我有一个 JSON 文件 其中包含 67790 1 kwh 319 4 现在我创建一个字典a dict我需要将其附加到 JSON 文件中 我尝试了这段代码 with open DATA FILENAME a as f json obj js
  • 解释 Python 中的数字范围

    在 Pylons Web 应用程序中 我需要获取一个字符串 例如 关于如何做到这一点有什么建议吗 我是 Python 新手 我还没有找到任何可以帮助解决此类问题的东西 该列表将是 1 2 3 45 46 48 49 50 51 77 使用
  • Python:如何将列表列表的元素转换为无向图?

    我有一个程序 可以检索 PubMed 出版物列表 并希望构建一个共同作者图 这意味着对于每篇文章 我想将每个作者 如果尚未存在 添加为顶点 并添加无向边 或增加每个合著者之间的权重 我设法编写了第一个程序 该程序检索每个出版物的作者列表 并
  • 发送用户注册密码,django-allauth

    我在 django 应用程序上使用 django alluth 进行身份验证 注册 我需要创建一个自定义注册表单 其中只有一个字段 电子邮件 密码将在服务器上生成 这是我创建的表格 from django import forms from
  • 使用 Python 的 matplotlib 选择在屏幕上显示哪些图形以及将哪些图形保存到文件中

    我想用Python创建不同的图形matplotlib pyplot 然后 我想将其中一些保存到文件中 而另一些则应使用show 命令 然而 show 显示all创建的数字 我可以通过调用来避免这种情况close 创建我不想在屏幕上显示的绘图
  • Python 类继承 - 诡异的动作

    我观察到类继承有一个奇怪的效果 对于我正在处理的项目 我正在创建一个类来充当另一个模块的类的包装器 我正在使用第 3 方 aeidon 模块 用于操作字幕文件 但问题可能不太具体 以下是您通常如何使用该模块 project aeidon P

随机推荐

  • 构造函数隐式删除

    下面列出了相关代码 您可以查看https godbolt org z 3GH8zD 我确实可以解决编译器编译错误 但我并不完全清楚其背后的原因 我将不胜感激对这个问题有一些帮助 struct A int x A int x 1 x x us
  • .obj 中已定义变量,但没有循环包含[重复]

    这个问题在这里已经有答案了 我知道 SO 上已经有很多类似的问题和解决方案 我读过它们 但没有一个能帮助我解决我的问题 我创建了一个用于记录的类 这是Logger h ifndef LOGGER H define LOGGER H name
  • java.io.NotSerializedException - org.omnifaces.taghandler.Converter

    我有一个在 Jboss 6 上使用 Primefaces 3 5 和 Omnifaces 1 5 的应用程序 使用 myfaces 2 1 5 尝试使用o converter我收到以下错误 org omnifaces taghandler
  • 使用数组求偶数和奇数平均值

    编写一个程序 从用户那里读取 10 个值的列表 将值放入数组中 程序应读取数组 然后计算并显示偶数输入值和奇数输入值的平均值 这应该使用对象 方法和测试器类来完成 我不明白为什么我收到错误 二元运算符的操作数类型错误 我不知道该改变什么 我
  • 使用 CloudFormation 模板部署 IIS 网站

    我有一个 Visual Studio C 部署包 zip 已将其推送到我的 S3 存储 我想运行我的 CloudFormation 脚本并让它创建 IIS 服务器的实例 我有用于此的脚本 然后将 Visual Studio 网站从 S3 存
  • 使用 cron 安排 R 脚本

    我正在尝试使用 cron 安排我的 R 脚本 但它不起作用 R 似乎在 cron 中找不到包 有人可以帮助我吗 谢谢 以下是我的 bash 脚本 source my profile home winie profile script R w
  • Java 8 链式方法参考?

    假设有一个典型的Java Bean class MyBean void setA String id void setB String id List
  • Javascript:sum(2)(3) //返回5是什么意思;

    这是返回其值的代码 function sum a return function b return a b sum 2 3 它返回 5 但如果我输入代码 function sum a function add b return a b re
  • 跟踪 Informix Client for Linux 的 ODBC 调用

    我尝试跟踪 Linux 上运行的程序中的 ODBC 函数调用 该程序动态链接 ODBC 管理器 然后连接到数据库并获取一些数据 我可以通过添加到 odbcinst ini 来使用 unixODBC 跟踪 ODBC 调用 ODBC Trace
  • 没有方法获取字节数组流[重复]

    这个问题在这里已经有答案了 我想获取字节数组流 但我发现Arrays没有获取字节数组流的方法 byte byteArr new byte 100 Arrays stream byteArr Compile time error 我的问题 为
  • tools.jar 丢失 - 但仅限于第一次调用(Tomcat 8/Java 8/ Axis)

    现在 我将 Web 应用程序升级到了 Java 8 在 Tomcat 8 中运行的 axis Web 服务遇到了奇怪的类加载问题 安装 Web 应用程序后第一次调用 Web 服务将导致 RuntimeException 和 在类路径中找不到
  • 关闭连接:java中的下一个

    我有 ResultSet 方法 我将在finally 块中关闭连接 public static ResultSet countdrcountcr String vforacid throws SQLException ResultSet r
  • 如何使用 Rocket 响应包含 JSON 数据的 POST 请求?

    我正在尝试使用创建后端火箭箱 fn main rocket ignite mount routes helloPost launch derive Debug PartialEq Eq RustcEncodable FromForm str
  • @Document 注释中的 MongoDB 和 SpEL 表达式

    我正在尝试使用 SpEL 根据我定义的一些规则将相同的文档加载到不同的集合中 首先从我所拥有的开始 首先是文件 Document collection mySpecialProvider getTargetCollectionName pu
  • 如何在 case 语句中循环遍历表中的值

    抱歉 SQL 新手 我有下表 用户可以更新和 或添加到 Project Type ID Name 1 Documents 2 DVD 3 Poster 我有一个查询 部分需要循环遍历每个记录并创建一个 数据透视 sum case when
  • 从 Qt 中的多线程绘图

    我正在用 Qt 编写一个程序 它运行 10 个工作线程来计算空间中物体的轨迹 他们还必须绘制物体的路径 我有一个派生 QGraphicsEllipseItem 的 Body 类 其中有一个 QPainterPath 模拟 类获取世界上的障碍
  • 网络应用程序共享相同的内存存储[重复]

    这个问题在这里已经有答案了 我在一个用于计算用户详细信息的应用程序中工作 但不知何故 一个用户的价值观会改变另一个用户的价值观 下面是代码片段 def Compute UserScore self details ques no try i
  • 如何在Azure Pipeline中将XCODE版本更新到13.4.1?

    我正在使用 azure pipeline 部署应用程序 出现以下错误 module compiled with Swift 5 6 1 cannot be imported by the Swift 5 5 我尝试过更改配置 但没有成功 任
  • xslt 排序输出 xml

    我正在尝试找到以下问题的解决方案 我正在开发 XSLT 转换 现在大约有 40KB 大 它将相当复杂的 XML 转换为一个非常简单的结构 如下所示
  • Cloud DataFlow 中的 Python 依赖项,requirements.txt 在本地工作,但在工作线程上不起作用

    我正在尝试使用requirements txt 文件运行我的Cloud DataFlow 作业 如此处所述 https cloud google com dataflow pipelines dependency python 我可以只构建