I want to build a .gpx file and was hoping to use gpxpy. I can see how to build such a file in memory, but I can't see how to write it out to disk.

Is it possible for gpxpy to write files?

1 Answer 1


With gpxpy no, but with simple Python yes

Using the example of the PyPi page

print('Created GPX:', gpx.to_xml())
with open("output.gpx", "w") as f:
    f.write( gpx.to_xml())

(gpxpy uses lxml or elementtree to parse .gpx files (in parser.py file))


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.