Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

AttributeError: 'MolDraw2DSVG' object has no attribute 'SetDrawOptions'

See original GitHub issue
import pandas as pd
import mols2grid

smiles = ["CCO", "c1ccccc1", "N", "CO", "O=S(=O)(-O)(-O)", "CCC", "CCC=O"]
df = pd.DataFrame({"smi": smiles,
                   "id": range(1, len(smiles) + 1)})
mg = mols2grid.MolGrid(df, smiles_col="smi", size=(110, 90))
mg.display(subset=["id", "img"], n_cols=7)

I was trying to visualize a list of SMILES, as shown in your colab. But I got the following error message.

AttributeError                            Traceback (most recent call last)
<ipython-input-26-cbf1ce952db4> in <module>
      7                    "id": range(1, len(smiles) + 1)})
      8 # setup the grid
----> 9 mg = mols2grid.MolGrid(df, smiles_col="smi", size=(110, 90))
     10 mg.display(subset=["id", "img"], n_cols=7)

~/anaconda3/lib/python3.7/site-packages/mols2grid/ in __init__(self, df, smiles_col, mol_col, coordGen, useSVG, mapping, **kwargs)
     74         dataframe.dropna(axis=0, subset=[mol_col], inplace=True)
     75         # generate drawings
---> 76         dataframe["img"] = dataframe[mol_col].apply(self.mol_to_img, **kwargs)
     77         self.dataframe = dataframe
     78         self.mol_col = mol_col

~/anaconda3/lib/python3.7/site-packages/pandas/core/ in apply(self, func, convert_dtype, args, **kwds)
   4133             else:
   4134                 values = self.astype(object)._values
-> 4135                 mapped = lib.map_infer(values, f, convert=convert_dtype)
   4137         if len(mapped) and isinstance(mapped[0], Series):

pandas/_libs/lib.pyx in pandas._libs.lib.map_infer()

~/anaconda3/lib/python3.7/site-packages/pandas/core/ in f(x)
   4119             def f(x):
-> 4120                 return func(x, *args, **kwds)
   4122         else:

~/anaconda3/lib/python3.7/site-packages/mols2grid/ in mol_to_img(self, mol, **kwargs)
    170         """Convert an RDKit mol to an HTML img tag containing a drawing of the
    171         molecule"""
--> 172         img = self.draw_mol(mol, **kwargs)
    173         if self.useSVG:
    174             return img

~/anaconda3/lib/python3.7/site-packages/mols2grid/ in draw_mol(self, mol, size, use_coords, MolDrawOptions, **kwargs)
    158         for key, value in kwargs.items():
    159             setattr(MolDrawOptions, key, value)
--> 160         d2d.SetDrawOptions(MolDrawOptions)
    161         if not use_coords:
    162             mol = deepcopy(mol)

AttributeError: 'MolDraw2DSVG' object has no attribute 'SetDrawOptions'

could you please take a look maybe? Thanks!

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

LiuCMUcommented, Jun 9, 2021

Hi, thank you very much! After updating RDKit to 2020.09.1.0, the script works well for me (sorry for the sluggish feedback, I don’t know why but my desktop takes a very long time to uninstall old RDKit vai conda:))

cbouycommented, Oct 11, 2021

I’ve updated the installation instructions on the readme file with the correct rdkit version.
If you install mols2grid from conda the correct rdkit version will now automatically be installed, which closes this issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

AttributeError: module 'rdkit.Chem.Draw.rdMolDraw2D' has no ...
but now I am getting: AttributeError: module 'rdkit.Chem.Draw.rdMolDraw2D' has no attribute 'MolDraw2DCairo' and when I look at rdkit.Chem.
Read more >
rdkit.Chem.Draw.rdMolDraw2D module
Generates and draws contours for data on a grid. drawer: the MolDraw2D object to use. data: numpy array with the data to be...
Read more >
AttributeError: 'Start' object has no attribute 'draw'
I am trying to set up a start game sprite that when you collide with it and press a button it will switch...
Read more >
Cédric Bouysset - ProLIF
The visualisation notebook now displays the protein with py3Dmol. Some examples for creating and displaying.
Read more >
New drawing options in the 2020.03 release - RDKit blog
You may not have developers working in your organization, ... Let's start by drawing a molecule using a MolDraw2DSVG() object: In [2]:.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found