Skip to content

Exception: tostring() has been removed. Please call tobytes() instead. #6

@Amrithasuresh

Description

@Amrithasuresh

I was working on this notebook tutorial.

I tried this step
'm = Chem.MolFromSmiles('COc1ccc2c(c1)[nH]c(n2)S@@Cc1ncc(c(c1C)OC)C')'
'm'


Exception Traceback (most recent call last)
/usr/local/lib/python2.7/dist-packages/IPython/core/formatters.pyc in call(self, obj)
309 method = get_real_method(obj, self.print_method)
310 if method is not None:
--> 311 return method()
312 return None
313 else:

/usr/lib/python2.7/dist-packages/rdkit/Chem/Draw/IPythonConsole.pyc in _toPNG(mol)
92 try:
93 img = Draw.MolToImage(mc,size=molSize,kekulize=kekulizeStructures,
---> 94 highlightAtoms=highlightAtoms)
95 except ValueError: # <- can happen on a kekulization failure
96 mc = copy.deepcopy(mol)

/usr/lib/python2.7/dist-packages/rdkit/Chem/Draw/init.pyc in MolToImage(mol, size, kekulize, wedgeBonds, fitImage, options, canvas, **kwargs)
92 raise ValueError('Null molecule provided')
93 if canvas is None:
---> 94 img,canvas=_createCanvas(size)
95 else:
96 img=None

/usr/lib/python2.7/dist-packages/rdkit/Chem/Draw/init.pyc in _createCanvas(size)
48 from PIL import Image
49 img = Image.new("RGBA",size,(0,0,0,0))
---> 50 canvas = Canvas(img)
51 else:
52 from rdkit.Chem.Draw.spingCanvas import Canvas

/usr/lib/python2.7/dist-packages/rdkit/Chem/Draw/cairoCanvas.pyc in init(self, image, size, ctx, imageType, fileName)
65 if image is not None:
66 try:
---> 67 imgd = image.tostring("raw","BGRA")
68 except SystemError:
69 r,g,b,a = image.split()

/usr/lib/python2.7/dist-packages/PIL/Image.pyc in tostring(self, *args, **kw)
693 def tostring(self, *args, **kw):
694 raise Exception("tostring() has been removed. " +
--> 695 "Please call tobytes() instead.")
696
697 def tobitmap(self, name="image"):

Exception: tostring() has been removed. Please call tobytes() instead.

As per this message. It seems I have to switch to older version of Pillow. I did that "pip install Pillow==2.1.0". Is that right?.

It does solve the issue. Just reporting it may help someone.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions