pan-os-python icon indicating copy to clipboard operation
pan-os-python copied to clipboard

panos use deprecated distutils library, not existing in current python (3.12 and later)

Open radekwo opened this issue 1 year ago • 4 comments

Describe the bug

The panos library is incompatible with Python 3.12 and newer, because it uses the deprecated distutils library. Distutils library was removed in python version 3.12

Expected behavior

Please rewrite panos library code, replace distutils.version and allow to use current python version (3.12, 3.13)

Current behavior

Traceback (most recent call last):
  File "C:\Users\radek\PycharmProjects\paloapi\test1.py", line 1, in <module>
    from panos import firewall
  File "C:\Users\radek\PycharmProjects\paloapi\.venv\Lib\site-packages\panos\__init__.py", line 35, in <module>
    from distutils.version import LooseVersion  # Used by PanOSVersion class
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ModuleNotFoundError: No module named 'distutils'
> python --version
Python 3.12.7

Steps to reproduce

Try run code below in python 3.12 or newer.

from panos import firewall
fw = firewall.Firewall("192.168.66.1", api_username="admin", api_password="admin")
print (fw.op("show system info"))

radekwo avatar Nov 03 '24 16:11 radekwo

Try pip install setuptools. This should fix the issue you're experiencing.

nikolay-matveev-kkr avatar Nov 05 '24 10:11 nikolay-matveev-kkr

While installing manually setuptools would fix the issue, the package requirements should be updated if it is required. This breaks CI/CD flows.

bmigette avatar Dec 12 '24 12:12 bmigette

pip install setuptools didn't make the trick for me.

GiHubNewbie avatar Apr 11 '25 18:04 GiHubNewbie

I have the core dependencies listed in my requirements.txt file as follows:

pan-python
pan-os-python>=1.12.1
setuptools>=75.1.0

Once you have them listed, the commands below should do the trick

pip install --upgrade pip
pip install --no-cache-dir -r requirements.txt
pip install pan-python==0.25.0

nikolay-matveev-kkr avatar Apr 17 '25 11:04 nikolay-matveev-kkr