When using the Python Matplotlib library, Python may throw the following error:
1 |
IOError: error while writing to output stream
|
Commonly this is caused because Python does not have access to the output stream -- in this case, usually some file that Matplotlib is attempting to write to. This is typical when the Python script is being used on a web server. For instance, the following code might not work if the directory "output" does not have write permissions on a server:
1 2 3 |
plt.figure() plt.plot(x, y) plt.savefig(output/example.pdf) |
How to set permissions will vary depending on the file system used on your web server. Contact the administrator of your server if you are not able to modify permissions yourself, or are unsure how to modify permissions.





