{"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":[{"note":"","wrong":null,"symbol":"PanDevice","correct":"from panos import PanDevice"},{"note":"Firewall is in the submodule panos.firewall, not panos directly","wrong":"from panos import Firewall","symbol":"Firewall","correct":"from panos.firewall import Firewall"},{"note":"Panorama class is in panos.panorama, not top-level","wrong":"from panos import Panorama","symbol":"Panorama","correct":"from panos.panorama import Panorama"},{"note":"AddressObject is in panos.objects","wrong":"from panos import AddressObject","symbol":"AddressObject","correct":"from panos.objects import AddressObject"}],"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,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Run 'pip install pan-os-python' (note the hyphens) to install the correct package.","cause":"Package not installed or installed in wrong environment.","error":"ModuleNotFoundError: No module named 'panos'"},{"fix":"Use 'from panos import PanDevice' (directly from panos) or check the changelog for version changes.","cause":"The PanDevice class was moved to panos.pandevice or deprecated.","error":"ImportError: cannot import name 'PanDevice' from 'panos'"},{"fix":"Use fw.refresh_system_info() (note lowercase) or fw.refresh() with appropriate parameters.","cause":"Method renamed or removed in newer versions.","error":"AttributeError: 'Firewall' object has no attribute 'refresh_system_info'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}