question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

OSError: [Errno cairo returned CAIRO_STATUS_WRITE_ERROR: b'error while writing to output stream'] 11

See original GitHub issue

Python 3.7.4 CairoSVG 2.4.2 Mac OS X 10.14.6

Input file: https://gist.github.com/brendabell/408c12703d92868ed73bcdf04cf92ec7

Note that I did include absolute height, width and viewBox. My code is as follows:

result = generator.generate()
text_file = open("{}.svg".format(machine), "w")
text_file.write(result)
text_file.close()
png_file = open("{}.png".format(machine), "w")
cairosvg.svg2png(bytestring=result,write_to=png_file)
png_file.close()

The generated SVG file seems to be perfect. I started getting the error after the following upgrades:

Python 2.7.16 -> 3.7.4 CairoSVG 1.0.22 -> 2.4.2

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:16 (7 by maintainers)

github_iconTop GitHub Comments

3reactions
liZecommented, Dec 26, 2019

It works for me. This error happens when you cannot write to your destination file, you should check the rights set on your destination folder (and your destination file if it already exists).

0reactions
shibababacommented, Jan 28, 2021

Code mistake ×png_file = open(“{}.png”.format(machine), “w”) ○png_file = open(“{}.png”.format(machine), “wb”)

Read more comments on GitHub >

github_iconTop Results From Across the Web

b'error while writing to output stream' on Google Cloud ...
The cairosvg package can't render a SVG with relative heights or widths without a viewBox attribute on the svg element.
Read more >
How to fix Cairo error 'error while writing to output stream'
when i run this code ggsave(), it tells me cairo error 'error while wirting to output stream'. Dose anyone know how to solve...
Read more >
Error handling: Cairo: A Vector Graphics Library
A status value of CAIRO_STATUS_SUCCESS represents no error and has an integer value of zero. ... error while writing to output stream (Since...
Read more >
Cannot export to Cairo PDF with localized characters in file path
Cannot export to Cairo PDF with localized characters in file path ... and Dia gives an error: "error while writing to export stream"....
Read more >
outputStreams stops writing someti… | Apple Developer Forums
But the data transfer sometimes stops suddenly without any error and after a few minutes it ... extension OutputStream { func write(data: Data)...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found