简体   繁体   English

Wand ImageMagick无法在Eclipse中将PDF转换为PNG,但可以在Terminal中使用

[英]Wand ImageMagick will not convert PDF to PNG in Eclipse, works in Terminal

I have a very strange issue. 我有一个很奇怪的问题。 I am trying to use the Wand ImageMagick binding for Python to convert a PDF to a PNG. 我正在尝试使用Python的Wand ImageMagick绑定将PDF转换为PNG。 I am running on Mac, installed ImageMagick with homebrew, and I have installed ghostscript and freetype, which are required for PDFs. 我在Mac上运行,使用自制软件安装了ImageMagick,并且安装了PDF所需的ghostscript和freetype。 I have the following code: 我有以下代码:

from wand.image import Image

img = Image(filename='/users/joelclark/Downloads/test.pdf')

img.save(filename='/users/joelclark/Downloads/test.png')

When I run this in Terminal using my python interpreter, it works great, the PNG file is generated. 当我使用python解释器在Terminal中运行此程序时,效果很好,生成了PNG文件。 However if I run this same code in Eclipse, I get the following error: 但是,如果我在Eclipse中运行相同的代码,则会出现以下错误:

Traceback (most recent call last):
  File "/Users/joelclark/Development/lims/mirage/test.py", line 11, in <module>
   img.save(filename='/users/joelclark/Downloads/test.png')
  File "/Users/joelclark/Development/lims/mirage-flask/flask/venv/lib/python2.7/site-packages/wand/image.py", line 2719, in save
    self.raise_exception()
  File "/Users/joelclark/Development/lims/mirage-flask/flask/venv/lib/python2.7/site-packages/wand/resource.py", line 222, in raise_exception
    raise e
wand.exceptions.WandError: wand contains no images `MagickWand-1' @ error/magick-image.c/MagickWriteImage/13115

Keep in mind that I am using the EXACT same interpreter in Eclipse that I am in Terminal. 请记住,我在Eclipse中使用的是与Terminal中相同的解释器。 I have also verified that the Python environments are the same, environment variables are the same, etc. It seems like an issue with Eclipse, but I honestly just cannot tell. 我还验证了Python环境是相同的,环境变量是相同的,等等。Eclipse似乎是一个问题,但老实说我无法确定。 I have also tried modifying permissions with chmod. 我也尝试过使用chmod修改权限。 When I did this the number after 'MagickWand' in the stack trace would change. 当我这样做时,堆栈跟踪中“ MagickWand”之后的数字将发生变化。 For example 'MagickWand-5' instead of 'MagickWand-1'. 例如,用“ MagickWand-5”代替“ MagickWand-1”。 I have no idea what this could mean but I figured I should mention it. 我不知道这意味着什么,但我想我应该提一下。 I read a similar post here Difference running python in PyCharm and in terminal but this was with PyCharm and not Eclipse. 我在这里读了一篇类似的文章, 区别是在PyCharm和终端中运行python,但这是PyCharm而非Eclipse。 Any help would be greatly appreciated. 任何帮助将不胜感激。 If there is any more information I can provide please let me know. 如果我能提供更多信息,请告诉我。

I found the answer. 我找到了答案。 My PATH in environment variable was not the same in Eclipse. 我在环境变量中的PATH在Eclipse中是不同的。 It was missing the /usr/local/bin path. 它缺少/ usr / local / bin路径。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM