3dmol / 3Dmol.js

WebGL accelerated JavaScript molecular graphics library
https://3dmol.org/
Other
785 stars 192 forks source link

No rendering in jupyter notebook #643

Closed phiweger closed 1 year ago

phiweger commented 1 year ago

Tryin to run the example code in a new jupyter installation fails:

import py3Dmol

view = py3Dmol.view(query='pdb:1ubq')
view.setStyle({'cartoon':{'color':'spectrum'}})
view

# looking into the chrom console log:
Uncaught (in promise) ReferenceError: $3Dmol is not defined
    at <anonymous>:27:1

Thanks for looking into this!

dkoes commented 1 year ago

Make sure you are using the latest version (2.0.0.post2). After upgrading, clear all outputs, save, refresh the page, and restart the kernel before testing.

edgar0011 commented 1 year ago

I would suggest, take care of the import and window global manually, as it worked fine in webpacl/babel environment.

import('3dmol/build/3Dmol-nojquery.js').then(($3Dmol) => { console.log('$3Dmol') console.log($3Dmol) window.$3Dmol = $3Dmol })

dkoes commented 1 year ago

You should not have to do that if you have the latest version. If you are running the latest version, I need to understand what the problem is so I can fix it (can't replicate here).

phiweger commented 1 year ago

Updating py3Dmol solved the problem, thank you @dkoes for the fast help!