Make ghostscript run from Windows command line natively

2

My problem: I am using Python to print plots which I usually output as .pdf file. Now I want to use .eps files, but Ghostscript is required (which I noticed because my Python console gave the error "Command gs not found").

Now I installed Ghostscript and I even went so far as to write an AutoRun into the registry under HKEY_CURRENT_USER -> Software -> Microsoft -> CommandProcessor with the value set to a .cmd file where I define an alias doskey gs=gswin64c (since on Windows the executable is named gswin64c but Python wants to run the Linux version gs).

Anyway, I still get the error. The bottom of the Python console prints: gs_distill your image.\nHere is the full report generated by ghostscript:\n\n' + fh.read()) TypeError: Can't convert 'bytes' object to str implicitly.

I believe the error is connected to Python not being able to run Ghostscript, but don't know where to go from here. Any solutions? Thanks in advance!

Ian

Posted 2016-07-21T12:38:02.800

Reputation: 158

Can you try add the python offending command you used? Give it a look here tooand maybe even more this answer. Ps Welcome on SuperUser

– Hastur – 2016-07-21T12:49:49.000

The offending line was plt.savefig(r'{}.eps'.format(filename), format="eps", dpi=1000). Anyhow, I kinda solved my problem by... well, rebooting. Seems like either Ghostscript or the registry edit needed a reboot to properly function. – Ian – 2016-07-21T13:18:56.750

"accept yourself" ... when you can. :). Good. – Hastur – 2016-07-21T13:26:48.473

In another 2 days! :D Thanks for the help, though! – Ian – 2016-07-21T13:27:41.137

Answers

2

Well, this is awkward. Rebooting solved my problem. It seems like I did the right steps, but without reboot it wouldn't work. Maybe this can be of help for someone else in the future.

Ian

Posted 2016-07-21T12:38:02.800

Reputation: 158

To reboot the computer is not always needed, can be enough to restart any explorer instance, but often helps.

– Hastur – 2016-07-21T13:27:49.637