2013-02-15 99 views
2

我使用Python 3.3。刚刚下载并安装了ghostscript 32位(GPL版本),但我无法导入它。无法导入ghostscript

我使用的命令:

import ghostscript 

,我收到错误消息:

ImportError: No module named ghostscript 

我有资本 'G' 试了一下,还是不行。有任何想法吗?

+0

你是如何安装软件包的?你在使用什么操作系统? – bernie 2013-02-15 19:19:28

+0

为了消除疑问,模块名称是'ghostscript';全部小写。参考:http://pypi.python.org/pypi/ghostscript – bernie 2013-02-15 19:20:07

+0

@bernie我正在使用Windows 7.我从这里运行Windows 32位的.exe文件:http://www.ghostscript.com/download/ gsdnld.html并成功安装。 – 2013-02-15 19:58:30

回答

5

您不需要安装Ghostscript,也可以安装Python模块。从这里下载:http://pypi.python.org/pypi/ghostscript并解压缩文件,然后运行python setup.py install

该模块未报告可与Python 3一起使用,因此您可能必须使用Python 2.此外,它在Windows上未经测试。

+1

上使用它,但使用python3对我来说非常容易。我所要做的就是在安装目录中运行python2到python3转换工具2to3:“2to3 -w /usr/local/lib/python3.5/dist-packages/ghostscript/” – 2017-06-23 17:04:07

0

我能够通过在导入包的文件下复制ghostscript repo来解决此问题。但由于ghostscript是用python2编写的,而且你使用的是python 3,所以你需要修正一些错误。例如:

no module named _gsprint under __init__.py 

(通过更新 “import _gsprint as gs” 到from . import _gsprint as gs固定)。

谢谢

+0

仅供参考,对我来说真的很简单使它适用于python3。我所要做的就是在安装目录中运行python2到python3转换工具2to3:“2to3 -w /usr/local/lib/python3.5/dist-packages/ghostscript/” – 2017-06-23 17:06:36