简体   繁体   English

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

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

Introduction and Explaination介绍与解释

i am trying deploy my code to azure function app (linux based, python code ) through CI.CD pipelines.我正在尝试通过 CI.CD 管道将我的代码部署到 azure function 应用程序(基于 Linux,python 代码)。 at first it worked fine but after few deployments, i am import error, library not found.起初它工作正常,但经过几次部署,我是导入错误,找不到库。 and when i check the artifacts, required files of libraries are missing.当我检查工件时,缺少所需的库文件。 i didnt changed anything in azure-pipelines.yml file.In azure-pipelines.yml i have added script for python to install libraries from requirements.txt.我没有更改 azure-pipelines.yml 文件中的任何内容。在 azure-pipelines.yml 中,我添加了 python 的脚本以从 requirements.txt 安装库。 does anyone have any idea about it有人知道吗

What I have tried我试过的

i have also added those bash commands in yml file but same issue.我还在 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'.

Issue问题

one more issue i am seeing is,我看到的另一个问题是,

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

You could set variable system.debug to true in pipeline and then queue a new build to get debug logs.您可以在管道中将变量system.debug 设置为 true ,然后将新构建排队以获取调试日志。 Reviewing the logs to check which directory that installing libraries from requirements.txt, and if this directory is included when you publishing the artifacts using the Publish Build Artifacts task .查看日志以检查从 requirements.txt 安装库的目录,以及在使用Publish Build Artifacts 任务发布工件时是否包含此目录。 See: Review logs to diagnose pipeline issues for guidance.请参阅: 查看日志以诊断管道问题以获取指导。

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

For those landing here from Google, the answer here is downgrading your build agent from ubuntu-20.04 to ubuntu-18.04对于那些从谷歌登陆这里的人,这里的答案是将你的构建代理从ubuntu-20.04降级到ubuntu-18.04

If using classic build pipeline designer in Azure DevOps that means changing your build agent specification in the build pipeline...如果在 Azure DevOps 中使用经典构建管道设计器,这意味着在构建管道中更改构建代理规范......

在此处输入图像描述

If using a github actions yaml pipeline that means如果使用 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