繁体   English   中英

python 软件包未通过 CI/CD 管道安装,导入错误,未找到 package

[英]python packages are not installed throughCI/CD pipelines,import error , package not found

介绍与解释

我正在尝试通过 CI.CD 管道将我的代码部署到 azure function 应用程序(基于 Linux,python 代码)。 起初它工作正常,但经过几次部署,我是导入错误,找不到库。 当我检查工件时,缺少所需的库文件。 我没有更改 azure-pipelines.yml 文件中的任何内容。在 azure-pipelines.yml 中,我添加了 python 的脚本以从 requirements.txt 安装库。 有人知道吗

我试过的

我还在 yml 文件中添加了那些 bash 命令,但同样的问题。

 bash: |
cd sub_folder
python3.6 -m venv worker_venv
source worker_venv/bin/activate
pip3.6 install setuptools
pip3.6 install -r requirements.txt
displayName: 'Install application dependencies'.

问题

我看到的另一个问题是,

Result: Failure Exception: ImportError: /lib/x86_64-linux-gnu/libm.so.6: version `GLIBC_2.29' not found (required by /home/site/wwwroot/worker_venv/lib/python3.6/site-packages/pyodbc.cpython-36m-x86_64-linux-gnu.so). Troubleshooting Guide: https://aka.ms/functions-modulenotfound Stack: File "/azure-functions-host/workers/python/3.6/LINUX/X64/azure_functions_worker/dispatcher.py", line 275, in _handle__function_load_request func_request.metadata.entry_point) File "/azure-functions-host/workers/python/3.6/LINUX/X64/azure_functions_worker/utils/wrappers.py", line 34, in call raise extend_exception_message(e, message) File "/azure-functions-host/workers/python/3.6/LINUX/X64/azure_functions_worker/utils/wrappers.py", line 32, in call return func(*args, **kwargs) File "/azure-functions-host/workers/python/3.6/LINUX/X64/azure_functions_worker/loader.py", line 76, in load_function mod = importlib.import_module(fullmodname) File "/usr/local/lib/python3.6/importlib/init.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "", line 994, in _gcd_import File "", line 971, in _find_and_load File "", line 941, in _find_and_load_unlocked File "", line 219, in _call_with_frames_removed File "", line 994, in _gcd_import File "", line 971, in _find_and_load File "", line 955, in _find_and_load_unlocked File "", line 665, in _load_unlocked File "", line 678, in exec_module File "", line 219, in _call_with_frames_removed File "/home/site/wwwroot/JFG_MATCHMERGE/init.py", line 7, in import pyodbc

您可以在管道中将变量system.debug 设置为 true ,然后将新构建排队以获取调试日志。 查看日志以检查从 requirements.txt 安装库的目录,以及在使用Publish Build Artifacts 任务发布工件时是否包含此目录。 请参阅: 查看日志以诊断管道问题以获取指导。

请参阅此 github 线程https://github.com/Azure/azure-functions-python-worker/issues/818

对于那些从谷歌登陆这里的人,这里的答案是将你的构建代理从ubuntu-20.04降级到ubuntu-18.04

如果在 Azure DevOps 中使用经典构建管道设计器,这意味着在构建管道中更改构建代理规范......

在此处输入图像描述

如果使用 github 动作 yaml 管道,这意味着

jobs:
  build-and-deploy-to-Azure:
    runs-on: ubuntu-18.04

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM