patrickfuller / imolecule

An embeddable webGL molecule viewer and file format converter.
http://patrickfuller.github.io/imolecule/
MIT License
86 stars 18 forks source link

ttributeError: 'module' object has no attribute 'json_formatter' #31

Closed olliemay closed 6 years ago

olliemay commented 6 years ago

Hi, i'm trying to use see how imolecules works in jupyter but i keep getting the following error when trying to follow you example:

import imolecule
imolecule.draw("CC1(C(N2C(S1)C(C2=O)NC(=O)CC3=CC=CC=C3)C(=O)O)C")
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-2-c19f0d58009f> in <module>()
----> 1 import imolecule
      2 imolecule.draw("CC1(C(N2C(S1)C(C2=O)NC(=O)CC3=CC=CC=C3)C(=O)O)C")

/usr/local/lib/python2.7/site-packages/imolecule/__init__.py in <module>()
----> 1 from imolecule.notebook import draw, generate, to_json  # noqa
      2 
      3 __title__ = 'imolecule'
      4 __version__ = '0.1.13'
      5 __author__ = 'Patrick Fuller'

/usr/local/lib/python2.7/site-packages/imolecule/notebook.py in <module>()
      5 from IPython.display import HTML, display
      6 
----> 7 import imolecule.json_formatter as json
      8 from imolecule import format_converter
      9 

AttributeError: 'module' object has no attribute 'json_formatter'

Python2.7 has been installed using home brew along with Swig and jupyter. Python dependences; ipython, pybel and openbabel have all been installed using pip2.

I have uninstalled and re-installed but that doesn't appear to work - any ideas?

Cheers, Ollie

patrickfuller commented 6 years ago

Just tried a clean install, and it worked for me:

▶ source activate py27                                                                                       
▶ pip install imolecule
...
▶ python
Python 2.7.13 |Continuum Analytics, Inc.| (default, Dec 20 2016, 23:09:15) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux2
>>> import imolecule.json_formatter as json
>>> 

Quick sanity checks:

olliemay commented 6 years ago

Hi Patrick,

I've uninstalled my brew python2.7 environment and install a new one using miniconda instead. Using conda as my package manger seems to have worked and has made life a lot easier!

I think there must have been an issue when I tried downloading the individual packages with pip and brew.

A bit off topic but how do I use your package on an Apache web server to display 2D structural formulas from SMILES?

Thanks again! Ollie

patrickfuller commented 6 years ago

For your other question, have a look at the examples.

If you want to convert SMILES to JSON, you'll have to think through a few steps. First, do you want a simple file server, or are you looking for more complex?

For a simple file server, you'll have to do everything with client-side javascript. You can use something like Kekule.js, then follow one of imolecule's javascript examples to see how it all ties in.

Writing your own server is more work, but gives you more functionality. This imolecule example uses server-side libraries to handle chemical conversion.

Both approaches have their advantages, and it's ultimately up to you.

Hope this helps!

jacknicoludis commented 5 years ago

I'm having this same issue. I installed python2.7 from conda. I used conda to install openbabel (conda install openbabel) and pip2 to install imolecule (pip2 install imolecule). When I go to /anaconda2/lib/python2.7/site-packages/imolecule/ the json_formatter.py file is there. Any other suggestions?

Screen Shot 2019-05-07 at 11 30 03 AM