Closed sodiumnitrate closed 11 months ago
t looks for a python 3.9 and spits out No module named 'nglview'
Because you have not installed nglview for python 3.9 yet?
You can try python3 -m jupyter notebook
, assuming that python3
is the 3.11.2
version that you installed nglview to.
Thank you for that. I know it's not installed in 3.9
, and I use the 3.11.2
kernel which can load the module. I had to downgrade notebook to a lower version as described here, and then run
jupyter nbextensions_configurator enable --user
jupyter nbextension enable --py --sys-prefix widgetsnbextension
jupyter nbextension enable --py --sys-prefix nglview
It now creates a big enough window as a display area, but does not display any protein. I even tried creating a simple html file and viewing that -- I can see the stage but no protein. I'm not sure if I'm doing something obviously wrong, but here's the html:
<!DOCTYPE html>
<html>
<head>
<title>test</title>
</head>
<body>
<script src="https://cdn.rawgit.com/arose/ngl/v2.0.0-dev.31/dist/ngl.js"></script>
<script>
var stage;
document.addEventListener("DOMContentLoaded", function () {
stage = new NGL.Stage("viewport");
stage.loadFile("rcsb://1crn", {defaultRepresentation: true});
});
</script>
<div id="viewport" style="width:800px; height:800px;"></div>
</body>
</html>
It just renders an 800x800 black box with no protein. This is similar to what I see in jupyter (a white box version anyway). Tried both firefox, safari, and chrome, but just a black box. I can see the example codepen, just not anything local.
I don't really know how to debug then.
It's very straight forward to use nglview
nowadays.
Basically, you just need to do pip install nglview
or conda install nglview -c conda-forge
without any enable
step in notebook or lab.
Update: both jupyter notebook and vscode can load local files, but not fetch them from pdb using show_pdbid
. The html version works when I change the file address to "rcsb://1crn.pdb"
. Not sure if this is the intended behavior.
That show_pdbid
issue should be fixed in https://github.com/nglviewer/nglview/pull/1086
Latest, v3.1.4, is supposed to work with VSCode.
I'm using vscode to edit
.ipynb
files. I'm also usingpyenv
to manage my python versions. I'm using3.11.2
, and have set my jupyter notebook kernel accordingly. I have:but only a thin white image with no apparent content shows up. I verify I'm using the correct python version within the notebook:
which outputs
I get no image when I use
jupyter notebook
either. Note that I had to add a kernel manually in/Users/iremaltan/Library/Jupyter/kernels
to be able to use the same python version. Thus, when I try to runit looks for a python 3.9 and spits out
No module named 'nglview'
. What do I do?