You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When attempting to deploy a Python function app using Python 3.12, the deployment fails because the Azure Functions Core Tools uses distlib version 0.3.0, which imports modules that were removed in Python 3.12 (imp and distutils).
The error occurs during the func pack command when creating a deployment package. The bundled distlib version tries to use these removed modules, causing the deployment to fail with errors like:
There was an error restoring dependencies. Traceback (most recent call last):
File "<frozen runpy>", line 198, in _run_module_as_main
File "<frozen runpy>", line 88, in _run_code
File "/opt/homebrew/Cellar/azure-functions-core-tools@4/4.0.7030/tools/python/packapp/__main__.py", line 14, in <module>
import distlib.wheel
File "/opt/homebrew/Cellar/azure-functions-core-tools@4/4.0.7030/tools/python/packapp/distlib/wheel.py", line 15, in <module>
import imp
ModuleNotFoundError: No module named 'imp'
and
There was an error restoring dependencies. Traceback (most recent call last):
File "<frozen runpy>", line 198, in _run_module_as_main
File "<frozen runpy>", line 88, in _run_code
File "/opt/homebrew/Cellar/azure-functions-core-tools@4/4.0.7030/tools/python/packapp/__main__.py", line 14, in <module>
import distlib.wheel
File "/opt/homebrew/Cellar/azure-functions-core-tools@4/4.0.7030/tools/python/packapp/distlib/wheel.py", line 12, in <module>
import distutils.util
ModuleNotFoundError: No module named 'distutils'
The issue is that both imp and distutils modules were removed in Python 3.12:
imp was deprecated since Python 3.4 and removed in 3.12 distutils was deprecated since Python 3.10 and removed in 3.12
This needs to be updated to a newer version of distlib that's compatible with Python 3.12. The latest version (0.3.8 as of this writing) has been updated to use importlib instead of imp and has removed dependencies on distutils.
Alternatively, the bundled version could be patched to:
Replace import imp with appropriate importlib imports
Replace distutils.util with equivalent functionality from setuptools
Replace imp.get_suffixes() with importlib.machinery.all_suffixes()
Version
4.0.7030
Description
When attempting to deploy a Python function app using Python 3.12, the deployment fails because the Azure Functions Core Tools uses
distlib
version 0.3.0, which imports modules that were removed in Python 3.12 (imp and distutils).The error occurs during the func pack command when creating a deployment package. The bundled
distlib
version tries to use these removed modules, causing the deployment to fail with errors like:and
The issue is that both imp and distutils modules were removed in Python 3.12:
imp was deprecated since Python 3.4 and removed in 3.12
distutils
was deprecated since Python 3.10 and removed in 3.12Steps to reproduce
or
The text was updated successfully, but these errors were encountered: