python - 在 Google Build 中使用 python 包
问题描述
在我requirements.txt
尝试下载python-ldap==3.2.0
. 但是,我需要这些依赖项。我应该如何使用 Google Build 下载这些?我尝试了以下但得到了错误:
Step #0 - "Dependency install": E: Unable to locate package libsasl2-dev
Step #0 - "Dependency install": E: Unable to locate package python-dev
Step #0 - "Dependency install": E: Unable to locate package libldap2-dev
Step #0 - "Dependency install": E: Unable to locate package libssl-dev
Step #0 - "Dependency install": Building dependency tree...
Step #0 - "Dependency install": Reading state information...
Finished Step #0 - "Dependency install"
2019/06/14 12:51:21 Step Step #0 - "Dependency install" finished
2019/06/14 12:51:21 status changed to "ERROR"
ERROR
ERROR: build step 0 "ubuntu" failed: exit status 100
2019/06/14 12:51:21 Error updating docker credentials: failed to update docker credentials: signal: killed
2019/06/14 12:51:21 Failed to delete homevol: exit status 1
2019/06/14 12:51:24 Build finished with ERROR status
cloudbuild.yaml
steps:
# Install Dependencies
- name: 'ubuntu'
id: Dependency install
args: ['apt-get', 'install',
'libsasl2-dev', 'python-dev', 'libldap2-dev', 'libssl-dev']
# Install Python Dependencies
- name: 'python'
id: Pip install
args: ['pip3', 'install', '-r', 'requirements.txt', '--user']
然后我尝试了
- name: 'ubuntu'
id: Dependency install
args: ['apt-get', 'update', '&&', 'apt-get', 'install',
'libsasl2-dev', 'python-dev', 'libldap2-dev', 'libssl-dev']
但这也失败了。
解决方案
Google Cloud Functions receives only your source code and a requirements.txt
file to indicate which python dependencies it uses.
The GCF manager internally and automatically install those dependencies on the python environment that will run you function, you install system libraries to the GCF environment, but you may use the ones that are available (here is the list). The library libldap2
that you require is not available. So you can open an issue on their issue tracker to ask for it.
Now, although it won't help you, the error on GC Build is happening because only the workspace (the starting working directory and everything inside it) is shared between steps. Each step starts a docker container with the image specified in the name
parameter and with the workspace mounted.
A more obvious demonstration that system changes are not shared is that using Ubuntu in one step, CentOS in another and Alpine in yet another. System libraries for each of them are very different, so they are clearly not shared.
推荐阅读
- javascript - DraftJS getBlocksAsArray() 在生产中返回一个数组,但在 dev 中返回一个数组(并且可以工作)
- node.js - 无法在 export.handler (/var/task/index.js:4:34) 读取未定义的属性“0”
- oracle - Oracle 按范围分区
- python - 如何使用 Matplotlib 更新实时绘图
- unity3d - 如何获取对象的准确触摸位置以在同一位置添加新的子对象
- c# - 如何在具有代理影响的公司网络中使用 C# 连接到“imap.gmail.com”
- sql-server - 将加密与动态数据屏蔽相结合
- c++ - 添加两个可变参数模板整数列表
- linux - 如何使用 mod_rewrite 阻止某些 HTTP 请求?
- kotlin - 如何在 kotlin 中拆分 unicode 空格