Python 3.11 Function Apps may fail to load with  No module named 'pkg_resources'

未关闭
#1,928 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 2 天内回复

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
42/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
azure, python
领域
backend

调研方向

Start by checking the Python 3.11 worker startup and function indexing behavior described in the issue, then look for where the worker image or dependency environment supplies setuptools. The issue identifies a mitigation in requirements.txt and the setuptools version change from 65.5.1 to 84.2.1. Done means affected apps can load functions when pkg_resources is imported; the issue does not name a test or code entry point.

由索引模型根据 Issue 内容生成。

描述

announcement

Description

Some Python 3.11 Azure Function Apps may fail to load their functions after receiving an updated platform image. Logs show:

ModuleNotFoundError: No module named 'pkg_resources'

The Functions host may start, but function indexing fails, leaving affected functions unavailable. This can occur without changes to application code or dependencies.

Apps are affected when their code—or an installed dependency—imports  pkg_resources  and relies on the platform image to provide it.

Cause

The updated Python 3.11 image upgraded setuptools from 65.5.1 to 84.2.1. Setuptools removed the deprecated  pkg_resources  module starting with 82.0.0.

Applications that do not explicitly install a compatible setuptools version can therefore lose access to  pkg_resources  when the underlying image updates.

Mitigation

Add the following dependency to your app’s  requirements.txt , replacing any existing setuptools requirement, and redeploy:

setuptools>=78.1.1,<82

This installs an application-local version of setuptools that still includes  pkg_resources , rather than relying on the platform image’s copy. Restarting the app alone does not install this dependency.

For a long-term solution, update affected dependencies or migrate to supported alternatives such as  importlib.metadata  and  importlib.resources .

主要语言
Python
星标
357
派生
118
平均合并
2 天 6 小时
30 天内合并 PR
10

环境准备

在 Codespaces 中打开

在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

Azure/azure-functions-python-worker 的其他 Issue

查看 Azure/azure-functions-python-worker 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。