{"id":21757,"library":"pykml","title":"pyKML","description":"Python KML (Keyhole Markup Language) library for parsing, constructing, and manipulating KML files. Version 0.2.0 is the current release; it is in maintenance mode with infrequent updates.","status":"maintenance","version":"0.2.0","language":"python","source_language":"en","source_url":"https://github.com/cleder/pykml","tags":["kml","geospatial","gps","google-earth","xml"],"install":[{"cmd":"pip install pykml","lang":"bash","label":"Default install from PyPI"}],"dependencies":[],"imports":[{"note":"","wrong":"","symbol":"KML","correct":"from pykml import KML"},{"note":"","wrong":"","symbol":"parser","correct":"from pykml import parser"},{"note":"parse is in pykml.parser submodule","wrong":"from pykml import parse","symbol":"parse","correct":"from pykml.parser import parse"},{"note":"No such module; use factory with ElementMaker","wrong":"from pykml.kml_parse import ...","symbol":"kml_parse","correct":"from pykml.factory import KML_ElementMaker as KML"}],"quickstart":{"code":"from pykml import parser\nfrom lxml import etree\n\nkml_str = '''<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<kml xmlns=\"http://www.opengis.net/kml/2.2\">\n  <Document>\n    <Placemark>\n      <name>Test</name>\n    </Placemark>\n  </Document>\n</kml>'''\n\nroot = parser.fromstring(kml_str)\nplacemark = root.Document.Placemark\nprint(placemark.name.text)","lang":"python","description":"Parse a KML string and access element attributes."},"warnings":[{"fix":"pip install lxml","message":"pykml requires lxml as a dependency; it is not automatically installed if you use pip without lxml already present. Install lxml explicitly.","severity":"gotcha","affected_versions":"all"},{"fix":"Use the pykml.factory module with KML_ElementMaker for generating KML.","message":"The library uses a non-standard namespace model with capitalized 'KML' classes, which can cause confusion when working with standard lxml methods.","severity":"deprecated","affected_versions":">=0.1.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Check for None: if root.Document: placemark = root.Document.Placemark","cause":"Accessing a child element that does not exist (e.g., Document.Placemark when Document is missing).","error":"AttributeError: 'NoneType' object has no attribute 'text'"},{"fix":"pip install lxml","cause":"lxml is not installed; pykml depends on it but does not declare it in install_requires.","error":"ModuleNotFoundError: No module named 'lxml'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}