【问题标题】:TypeError when importing ghostscript on Python在 Python 上导入 ghostscript 时出现 TypeError
【发布时间】:2017-03-07 18:04:19
【问题描述】:

我已经在我的机器上安装了 ghostscript,位于

C:\Program Files (x86)\gs\gs9.20

并通过 pip 安装了 python 模块

pip install ghostscript

但是,当我尝试导入 ghostscript 时出现此错误

>>> import ghostscript
Traceback (most recent call last):
  File "<pyshell#0>", line 1, in <module>
    import ghostscript
  File "C:\Python27\lib\site-packages\ghostscript\__init__.py", line 33, in <module>
    import _gsprint as gs
  File "C:\Python27\lib\site-packages\ghostscript\_gsprint.py", line 281, in <module>
    libgs = windll.LoadLibrary(libgs)
  File "C:\Python27\lib\ctypes\__init__.py", line 440, in LoadLibrary
return self._dlltype(name)    
  File "C:\Python27\lib\ctypes\__init__.py", line 362, in __init__
self._handle = _dlopen(self._name, mode)
TypeError: LoadLibrary() argument 1 must be string, not Unicode

【问题讨论】:

  • 您使用的是哪个版本的 Python?这看起来像是 Python 2.7.13 (bugs.python.org/issue29082) 中的一个错误。尝试升级到 2.7 的最新版本。
  • 我使用的是 v2.7.13,所以我现在升级看看是否可以解决问题
  • python网站说v2.7.13是最新版本
  • 确实,这是最新的。虽然看起来你可以返回一个版本来解决这个问题! stackoverflow.com/a/41655617/245915
  • 降级到版本 12 解决了问题

标签: python-2.7 ctypes ghostscript


【解决方案1】:

Ghost 脚本在 python v2.7.13 中无法运行,因此运行 v2.7.12 安装并通过 v2.7.12 导入没有错误

【讨论】:

    猜你喜欢
    • 2023-02-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-05-31
    相关资源
    最近更新 更多