Gangmax Blog

Fix The "pkg_resources is deprecated as an API" Warning

When I was running a tool compiled by PyInstaller with Python code, I got the following warning message:

1
PyInstaller/loader/pyimod02_importers.py:450: UserWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html. The pkg_resources package is slated for removal as early as 2025-11-30. Refrain from using this package or pin to Setuptools<81.

I googled this and got the solution here, which was to add the “–exclude-module pkg_resources” argument in the “pyinstaller” command to exclude the “pkg_resources” package from the build.

Comments