我正在尝试使用魔杖打开PDF作为图像。如果我在Jupyter Notebook中运行以下代码,则可以正常工作。如果我从命令提示符处将代码作为脚本运行,则会收到错误消息。由于某些原因,当模块在Jupyter Notebook之外运行时将无法加载。有没有人有什么建议?
Windows
Python 3.7.2(64位)
from wand.image import Image
with Image(filename="C:/test.pdf", resolution=300) as img:
print(type(img))
这是错误消息:
Traceback (most recent call last):
File "C:\Untitled.py", line 7, in <module>
from wand.image import Image
File "C:\Users\spencer.rand\AppData\Local\Programs\Python\Python37\lib\site-packages\wand\image.py", line 18, in <module>
from . import compat
File "C:\Users\spencer.rand\AppData\Local\Programs\Python\Python37\lib\site-packages\wand\compat.py", line 25, in <module>
abc = collections.abc if PY3 else collections
File "C:\Users\spencer.rand\AppData\Local\Programs\Python\Python37\lib\collections\__init__.py", line 55, in __getattr__
raise AttributeError(f'module {__name__!r} has no attribute {name!r}')
AttributeError: module 'collections' has no attribute 'abc'
答案 0 :(得分:3)
好像两周前就解决了魔杖和收藏品的问题:https://github.com/emcconville/wand/pull/398
尝试更新您的魔杖安装:n_rooms = widgets.IntSlider(
min=1,
max=5,
description='number of rooms:',
layout=Layout(width='30%'),
style=style,
disabled=False)