Importing Ghostscript in Python on Windows 8

天涯浪子 提交于 2021-02-19 01:45:07

问题


I've been trying to import ghostscript into Python in order to convert pdf files to a .tiff format.

I am using Python version 2.7.10 on Windows 8.

I have successfully downloaded and installed ghostscript using pip, and it appears in the correct location (...\Anaconda\Lib\sitepackages). I've confirmed that other packages located in this directory can be imported into Python.

I am using the command import ghostscript

When I do so, I get an error message:

RuntimeError: Can not find Ghostscript DLL in registry

The traceback indicates that calling the file "ghoscript_init_.py" successfully imports _gsprint as gs.

However, when the import function attempts to access "ghostscript_gsprint.py", it produces the RuntimeError where it is unable to find the Ghostscript DLL.

I would be very grateful for any advice or tips. Thanks!


回答1:


As well as installing ghostscript python bindings from PyPI with pip install ghostscript, you also need to install the correct Ghostscript program for your platform, as described on the PyPI page. That page states that version 8.x is required, but I'm currently using 9.2 successfully.

The download links are here.




回答2:


Jamie's answer is not very helpful, OP is saying that he has indeed downloaded and installed ghostscript and even posted that he's using a python 2.7 which is supposed to be supported by ghostscript no problem.

I got the same error: RuntimeError: Can not find Ghostscript DLL in registry

My problem was actually that I had Python(3.6) 64bit installed while having Ghostscript 32bit installed. Uninstalling the 32bit Ghostscript and installing 64bit Ghostscript resolved the issue.

You can check your python version by running python.exe and checking the header message.

python

Python 3.6.6 |Anaconda, Inc.| (default, Jun 28 2018, 11:27:44) [MSC v.1900 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information.



来源:https://stackoverflow.com/questions/31886385/importing-ghostscript-in-python-on-windows-8

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!