{"id":24194,"library":"pan-os-python","title":"pan-os-python","description":"Palo Alto Networks SDK for Python to interact with PanOS devices via XML API. Version 1.12.5, active development with regular bugfix releases. Supports Python >=2.7 but not 3.0-3.4.","status":"active","version":"1.12.5","language":"python","source_language":"en","source_url":"https://github.com/PaloAltoNetworks/pan-os-python","tags":["palo-alto","firewall","pan-os","network-security","sdk","api"],"install":[{"cmd":"pip install pan-os-python","lang":"bash","label":"Install from PyPI"}],"dependencies":[{"reason":"Core dependency for PanOS API interaction","package":"pan-python","optional":false},{"reason":"XML parsing of API responses","package":"xmltodict","optional":false},{"reason":"Used for HTTP(S) API calls","package":"requests","optional":false}],"imports":[{"wrong":"from panos import PanDevice","symbol":"PanDevice","correct":"from panos import PanDevice"}],"quickstart":{"code":"import os\nfrom panos.firewall import Firewall\nfrom panos.policies import Rulebase, SecurityRule\n\n# Connect to firewall using environment variables\nfw = Firewall(os.environ.get('PANOS_HOST', ''), os.environ.get('PANOS_USER', 'admin'), os.environ.get('PANOS_PASS', 'admin'))\n# Retrieve running config\nfw.refresh_system_info()\nprint(f\"Connected to {fw.hostname} running PanOS {fw.version}\")\n\n# List security rules\nrulebase = Rulebase()\nfw.add(rulebase)\nrules = SecurityRule.refreshall(rulebase)\nfor rule in rules:\n    print(rule.name, rule.to, rule.from_)","lang":"python","description":"Connect to a Palo Alto Networks firewall and list security rules."},"warnings":[{"fix":"Use 'from_' (with underscore) as the attribute name in Python, e.g., rule.from_","message":"In v1.9+, the 'from' attribute of SecurityRule is reserved, use 'from_' in Python code.","severity":"breaking","affected_versions":">=1.9.0"},{"fix":"Replace PanDevice(hostname, api_username, api_password) with Firewall(hostname, api_username, api_password) or Panorama(...).","message":"The PanDevice class no longer auto-detects whether device is a firewall or panorama in v1.12+. Use explicit Firewall or Panorama constructors.","severity":"breaking","affected_versions":">=1.12.0"},{"fix":"After adding an object to a device, call .create() on it or use .refreshall() to retrieve existing configurations.","message":"Many objects like 'tag' are not refreshed automatically after creation. You must call refresh() or create() before accessing sub-elements.","severity":"gotcha","affected_versions":"all"},{"fix":"Use fw.commit(sync=True) to block until the commit finishes, or handle job polling manually with commit() and waitfor()","message":"Commit operations are not synchronous by default. The commit() method returns a job ID; you need to poll for completion.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"search_vec":"'-3.4':33 '1.12.5':20 '2.7':29 '3.0':32 'activ':21 'alto':6,36 'api':18,45 'bugfix':25 'develop':22 'devic':15 'firewal':37 'interact':12 'network':7,42 'network-secur':41 'os':3,40 'palo':5,35 'palo-alto':34 'pan':2,39 'pan-o':38 'pan-os-python':1 'pano':14 'python':4,10,28 'regular':24 'releas':26 'sdk':8,44 'secur':43 'support':27 'version':19 'via':16 'xml':17","created_at":"2026-05-01T08:11:47.326328+00:00","updated_at":"2026-05-01T08:11:47.326328+00:00","problems":{"verify_error":"Traceback (most recent call last):\n  File \"<string>\", line 1, in <module>\nImportError: cannot import name 'PanDevice' from 'panos' (/tmp/tmpr5cpk0f6/venv/lib/python3.12/site-packages/panos/__init__.py)"},"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"1.13.0","cli_name":"","cli_version":null,"type":"library","homepage":"https://docs.paloaltonetworks.com/pan-os/11-0/pan-os-python-sdk","github":"https://github.com/PaloAltoNetworks/pan-os-python","docs":"https://pan-os-python.readthedocs.io","changelog":null,"pypi":"https://pypi.org/project/pan-os-python/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops","http-networking","auth-security"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"import_fail","verified_at":"2026-07-03","last_verified":"2026-07-03","next_check":"2026-07-10","install_tag":null}}