Discussion:
[Rdkit-discuss] 2D image issues
r***@gmail.com
2009-12-31 14:37:00 UTC
Permalink
Happy new year, RDKit-ers!

I've installed the latest RDKit on a Fedora 10 system and it seems to be
functioning will except for drawing 2D images of molecules. I have PIL and
from rdkit import Chem
from rdkit.Chem import Draw
mol = Chem.MolFromSmiles('c1ccncc1CC(=O)O')
Draw.MolToImageFile(mol,'test.png')
I get this:

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/opt/RDKit_Q32009_1/rdkit/Chem/Draw/__init__.py", line 104, in
MolToImageFile
img =
MolToImage(mol,size=size,kekulize=kekulize,wedgeBonds=wedgeBonds,highlightAtoms=highlightAtoms)
File "/opt/RDKit_Q32009_1/rdkit/Chem/Draw/__init__.py", line 50, in
MolToImage
drawer.AddMol(mol,highlightAtoms=highlightAtoms)
File "/opt/RDKit_Q32009_1/rdkit/Chem/Draw/MolDrawing.py", line 398, in
AddMol
highlightIt=(highlightAtoms and idx in highlightAtoms))
File "/opt/RDKit_Q32009_1/rdkit/Chem/Draw/MolDrawing.py", line 270, in
_drawLabel
addCanvasText(canvas,label,(x1,y1),font,color)
File "/opt/RDKit_Q32009_1/rdkit/Chem/Draw/aggCanvas.py", line 75, in
addCanvasText
font = Font(color,faceMap[font.face],size=font.size)
IOError: cannot load font (no text renderer)



I've seen this before on a Red Hat 5 system but it resolved itself after
rebooting the system. Not so in this particular case. I've also googled for
the error messages but haven't found anything useful.

Any ideas?

-Kirk
Greg Landrum
2010-01-04 05:08:14 UTC
Permalink
Dear Kirk,
Post by r***@gmail.com
Happy new year, RDKit-ers!
Thanks! you too.
Post by r***@gmail.com
I've installed the latest RDKit on a Fedora 10 system and it seems to be
functioning will except for drawing 2D images of molecules. I have PIL and
from rdkit import Chem
from rdkit.Chem import Draw
mol = Chem.MolFromSmiles('c1ccncc1CC(=O)O')
Draw.MolToImageFile(mol,'test.png')
<snip>
Post by r***@gmail.com
font = Font(color,faceMap[font.face],size=font.size)
IOError: cannot load font (no text renderer)
I believe that this problem occurs when aggdraw (and probably PIL) are
built without freetype2 support. Try installing the development
packages for freetype2 on the new machine and then rebuilding aggdraw.
Check through the output of the aggdraw build to make sure that it's
actually finding the freetype libraries.

Hope this helps,
-greg
Robert DeLisle
2010-01-17 06:14:55 UTC
Permalink
I was able to get the code built and working on a Fedora 12 system.
Initially I had the same error, but through some digging I found that I
needed to set the FREETYPE_ROOT variable to '/usr/' in the aggdraw setup.py
file. The latest freetype2 packages are already installed and all the
necessary libraries, includes, and code can be found within the /usr/
directory tree.

Thanks for the tip, Greg!

-Kirk
Post by Greg Landrum
Dear Kirk,
Post by r***@gmail.com
Happy new year, RDKit-ers!
Thanks! you too.
Post by r***@gmail.com
I've installed the latest RDKit on a Fedora 10 system and it seems to be
functioning will except for drawing 2D images of molecules. I have PIL
and
Post by r***@gmail.com
from rdkit import Chem
from rdkit.Chem import Draw
mol = Chem.MolFromSmiles('c1ccncc1CC(=O)O')
Draw.MolToImageFile(mol,'test.png')
<snip>
Post by r***@gmail.com
font = Font(color,faceMap[font.face],size=font.size)
IOError: cannot load font (no text renderer)
I believe that this problem occurs when aggdraw (and probably PIL) are
built without freetype2 support. Try installing the development
packages for freetype2 on the new machine and then rebuilding aggdraw.
Check through the output of the aggdraw build to make sure that it's
actually finding the freetype libraries.
Hope this helps,
-greg
Loading...