PyCharm上的魔杖和Ghostscript问题 [英] Wand and ghostscript issue on PyCharm

查看:309
本文介绍了PyCharm上的魔杖和Ghostscript问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我已经安装了Wand,Ghostscript,ImageMagick.我正在尝试将PDF转换为图像.我的代码如下.

So I have installed Wand, Ghostscript, ImageMagick. I am trying to convert a PDF to Image. My Code is as following.

代码:

from wand.image import Image
image_pdf = Image(filename="/<fullpath>/xyz.pdf", resolution=500)
image_jpeg = image_pdf.convert('jpeg')
print (len(image_jpeg.sequence))

当我通过终端运行代码时(我的意思是打开python终端并将代码粘贴到那里),它可以工作.但是相同的代码在PyCharm中失败.

When I run the code through terminal (I mean open python terminal and paste the code there), it works. But the same code fails in PyCharm.

错误:

File "/usr/local/lib/python2.7/site-packages/wand/resource.py", line 222, in raise_exception
raise e
wand.exceptions.DelegateError: FailedToExecuteCommand `'gs' -sstdout=%stderr -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 '-sDEVICE=pngalpha' -dTextAlphaBits=4 -dGraphicsAlphaBits=4 '-r500x500'  '-sOutputFile=/var/folders/61/7q0vknr92mndbbgzqvsk3xl4r4yw3f/T/magick-24738xypZ5LDqNaTJ%d' '-f/var/folders/61/7q0vknr92mndbbgzqvsk3xl4r4yw3f/T/magick-24738Tr70PW391Vdt' '-f/var/folders/61/7q0vknr92mndbbgzqvsk3xl4r4yw3f/T/magick-24738wI4q1Lv6Aich'' (1) @ error/pdf.c/InvokePDFDelegate/292
Exception TypeError: TypeError("object of type 'NoneType' has no len()",) in <bound method Image.__del__ of <wand.image.Image: (empty)>> ignored

我在终端中检查了python版本 which python2我得到/usr/local/bin/python2

I checked the python version in terminal which python2 and I get /usr/local/bin/python2

我的PyCharm pythton解释器位于/usr/local/Cellar/python/2.7.13_1/....

My PyCharm pythton Interpreter is located at /usr/local/Cellar/python/2.7.13_1/....

我在这里想念什么?

推荐答案

您应该通过使用 virtualenvwrapper .

You should look to isolate your Python environment from your system Python (and yes, your Homebrew installation would be considered a system Python installation too) by using virtualenvwrapper.

据我所见,您的系统使用的Python与PyCharm使用的Python不同.可以通过以下方法解决此问题:转到设置">项目解释器",然后为您的解释器选择正确的路径...

From what I'm seeing, the Python that your system is using is not the same Python that PyCharm is using. While that can be fixed by going to Settings > Project Interpreter and selecting the right path for your interpreter...

...最好确保将项目需要的所有必需依赖项安装在隔离的虚拟环境中.

...it would be best to ensure that you install all of the necessary dependencies your project needs in an isolated virtual environment instead.

这篇关于PyCharm上的魔杖和Ghostscript问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆