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

Offen
#1,928 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 2 Tagen

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Anfängerfreundlichkeit
42/100
Issue-Typ
Bug
Klarheit
Klar beschrieben
Aktivitätsstatus
Aktiv
Tech-Stack
azure, python
Bereich
backend

Rechercherichtung

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.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

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 .

Vorherrschende Sprache
Python
Sterne
357
Forks
118
Ø Merge
2 T. 6 Std.
Gemergte PRs (30 T.)
10

Entwicklungsumgebung

In Codespaces öffnen

Startet den Dev-Container des Projekts im Browser, mit Ihrem eigenen GitHub-Konto.

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus Azure/azure-functions-python-worker

Alle Issues in Azure/azure-functions-python-worker

Ähnliche Issues

Weitere Issues zu Python

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.