PaloAltoNetworks / PaloAltoNetworks/pan-os-python

pan-os-python is incompatible with python 3.12 due to missing `distutils` package

Open
#529 1 comment 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Python
Stars
400
Forks
199
PR merge metrics
No merged PRs in 30d

Description

Describe the bug

The distutils package which is required for the version checks in pan-os-python has been removed in python 3.12.

PEP 632: Remove the distutils package. See the migration guide for advice replacing the APIs it provided. The third-party Setuptools package continues to provide distutils, if you still require it in Python 3.12 and beyond.

Expected behavior

pan-os-python should work.

Current behavior

File "/Users/someuser/.local/pipx/venvs/somevenv/lib/python3.12/site-packages/panos/init.py", line 35, in
from distutils.version import LooseVersion # Used by PanOSVersion class
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ModuleNotFoundError: No module named 'distutils'

Possible solution

Follow the migration guide and use the packaging package instead.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in panos/init.py at the distutils.version import used by PanOSVersion. Read the linked PEP 632 migration advice and check the packaging-based replacement. Done means pan-os-python imports and works under Python 3.12 without the ModuleNotFoundError.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.