简体   繁体   中英

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. 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. does anyone have any idea about it

What I have tried

i have also added those bash commands in yml file but same issue.

 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. 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 . See: Review logs to diagnose pipeline issues for guidance.

Please see this github thread 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

If using classic build pipeline designer in Azure DevOps that means changing your build agent specification in the build pipeline...

在此处输入图像描述

If using a github actions yaml pipeline that means

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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