Azure / Azure/azure-cli-extensions

UserWarning: pkg_resources is deprecated as an API

Open
#8,953 7 comments 4 reactions 1 assignee Claimed by @necusjz View on GitHub
Auto-Assign customer-reported Network - Bastion question Service Attention
Dominant language
Python
Stars
454
Forks
1.7k
Avg merge
2d 19h
Merged PRs (30d)
64

Description

### Describe the bug

When running `az network bastion ssh` commands we recieve

/.azure/cliextensions/bastion/azext_bastion/custom.py:107: 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.
from pkg_resources import parse_version

This warning breaks our tooling, can the warning be silenced or the pkg_resource dependency be removed?

We've tried
1. export PYTHONWARNINGS=ignore
2. --only-show-errors
3. pip install setuptools==80.8.0 --force-reinstall

Ref (was fixed on other parts of az cli):
https://github.com/Azure/azure-cli/issues/31591

Versions:
azure-cli 2.75.0
core 2.75.0
telemetry 1.1.0
Extensions:
azure-devops 1.0.2
bastion 1.4.1
ssh 2.0.6

### Related command

`az network bastion ssh`

### Errors

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.
from pkg_resources import parse_version

### Issue script & Debug output

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.
from pkg_resources import parse_version

### Expected behavior

No Warning should be produced, the shell should be shown

### Environment Summary

azure-cli 2.75.0

core 2.75.0
telemetry 1.1.0

Extensions:
azure-devops 1.0.2
bastion 1.4.1
ssh 2.0.6

Dependencies:
msal 1.33.0b1
azure-mgmt-resource 23.3.0

Python location '/opt/az/bin/python3'
Config directory '/home/alex/.azure'
Extensions directory '/home/alex/.azure/cliextensions'

Python (Linux) 3.12.10 (main, Jun 24 2025, 10:15:05) [GCC 11.4.0]

Legal docs and information: aka.ms/AzureCliLegal

Your CLI is up-to-date.

### Additional context

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.