The two problems you describe are unrelated and we need to discuss them separately. Let’s refer to them as problem I and II.
Problem I:
This is unexpected. Could you please describe in more detail which operation takes longer than usual? Is it the call to the Viewport.render_image()
function? If you have been doing this in a Jupyter notebook, it could be useful to test this also outside Jupyter from a standalone Python program to see if it makes any difference. Note that you can include a call to the ovito.enable_logging() function in your program to see some more information on what OVITO is currently doing.
Problem II:
So far I could not reproduce the issue in my local environment (macOS). Perhaps because I used different installation steps. Here is what I did: First, I’ve created a new Conda environment named “jupyter”, installing the ovito
package and ipywidgets
. The latter is needed by the create_jupyter_widget()
function:
conda create -n jupyter --strict-channel-priority -c https://conda.ovito.org -c conda-forge ovito==3.9.1 ipywidgets
Next, I created a Jupyter notebook in VS Code and selected the “jupyter” conda environment as active interpreter for the notebook. The following cell code produces a black viewport widget (as it should be):
from ovito.vis import Viewport
vp = Viewport()
vp.create_jupyter_widget()
In VS Code’s “Output” terminal (after selecting “Jupyter”), I see the following log output:
10:24:49.004 [info] User belongs to experiment group 'FastKernelPicker'
10:24:49.004 [info] User belongs to experiment group 'NewRemoteUriStorage'
10:24:49.004 [info] User belongs to experiment group 'PasswordManager'
10:24:49.004 [info] User belongs to experiment group 'NewJupyterSession'
10:24:49.207 [info] Start refreshing Kernel Picker (1692001489207)
10:24:49.208 [info] Using Pylance
10:24:49.475 [info] Starting Kernel startUsingPythonInterpreter, .jvsc74a57bd04ca29c47d6b62bf13677655d657ac3421b0c2ea5d37db50160fad649d39e7893.~/miniconda3/envs/jupyter/python.~/miniconda3/envs/jupyter/python.-m#ipykernel_launcher (Python Path: ~/miniconda3/envs/jupyter/bin/python, Conda, jupyter, 3.10.6) for '~/prj/ovito-pro/tests/scripts/Untitled.ipynb' (disableUI=true)
10:24:50.017 [info] Process Execution: ~/miniconda3/envs/jupyter/bin/python -m pip list
10:24:50.212 [info] Process Execution: ~/miniconda3/envs/jupyter/bin/python -c "import ipykernel; print(ipykernel.__version__); print("5dc3a68c-e34e-4080-9c3e-2a532b2ccb4d"); print(ipykernel.__file__)"
10:24:50.215 [info] Process Execution: ~/miniconda3/envs/jupyter/bin/python -m ipykernel_launcher --ip=127.0.0.1 --stdin=9003 --control=9001 --hb=9000 --Session.signature_scheme="hmac-sha256" --Session.key=b"047a77c5-41a9-4d06-bcde-609043cf2c0f" --shell=9002 --transport="tcp" --iopub=9004 --f=~/Library/Jupyter/runtime/kernel-v2-39151f0gm5nF3qgx7.json
> cwd: ~/prj/ovito-pro/tests/scripts
10:24:50.258 [info] End refreshing Kernel Picker (1692001489207)
10:24:50.459 [info] ipykernel version & path 6.25.1, ~/miniconda3/envs/jupyter/lib/python3.11/site-packages/ipykernel/__init__.py for ~/miniconda3/envs/jupyter/bin/python
10:24:50.751 [warn] StdErr from Kernel Process 0.00s - Debugger warning: It seems that frozen modules are being used, which may
0.00s - make the debugger miss breakpoints. Please pass -Xfrozen_modules=off
0.00s - to python to disable frozen modules.
10:24:50.751 [warn] StdErr from Kernel Process 0.00s - Note: Debugging will proceed. Set PYDEVD_DISABLE_FILE_VALIDATION=1 to disable this validation.
10:24:51.076 [info] Started Kernel jupyter (Python 3.10.6) (pid: 39607)
10:24:51.076 [info] Started new session 1bf59fb7-fd2f-4e3f-81cf-aae25846253d
10:24:51.146 [info] Process Execution: ~/miniconda3/envs/jupyter/bin/python ~/.vscode/extensions/ms-toolsai.jupyter-2023.7.1002162226-darwin-arm64/pythonFiles/printJupyterDataDir.py
10:25:18.143 [info] Handle Execution of Cells 0 for ~/prj/ovito-pro/tests/scripts/Untitled.ipynb
10:25:18.149 [info] Kernel acknowledged execution of cell 0 @ 1692001518146
10:25:19.220 [info] End cell 0 execution @ 1692001519218, started @ 1692001518146, elapsed time = 1.072s
10:27:51.594 [info] Handle Execution of Cells 0 for ~/prj/ovito-pro/tests/scripts/Untitled.ipynb
10:27:51.612 [info] Kernel acknowledged execution of cell 0 @ 1692001671607
10:27:51.614 [info] End cell 0 execution @ 1692001671612, started @ 1692001671607, elapsed time = 0.005s
10:27:54.861 [info] Dispose Kernel '~/prj/ovito-pro/tests/scripts/Untitled.ipynb' associated with '~/prj/ovito-pro/tests/scripts/Untitled.ipynb'
10:27:54.861 [info] Dispose Kernel process 39607.
10:28:00.101 [info] Start refreshing Interpreter Kernel Picker
10:28:00.102 [info] Start refreshing Kernel Picker (1692001680102)
10:28:00.116 [info] Starting Kernel startUsingPythonInterpreter, .jvsc74a57bd04ca29c47d6b62bf13677655d657ac3421b0c2ea5d37db50160fad649d39e7893.~/miniconda3/envs/jupyter/python.~/miniconda3/envs/jupyter/python.-m#ipykernel_launcher (Python Path: ~/miniconda3/envs/jupyter/bin/python, Conda, jupyter, 3.10.6) for '~/prj/ovito-pro/tests/scripts/Untitled.ipynb' (disableUI=true)
10:28:00.123 [info] Process Execution: ~/miniconda3/envs/jupyter/bin/python -c "import ipykernel; print(ipykernel.__version__); print("5dc3a68c-e34e-4080-9c3e-2a532b2ccb4d"); print(ipykernel.__file__)"
10:28:00.141 [info] Process Execution: ~/miniconda3/envs/jupyter/bin/python -m ipykernel_launcher --ip=127.0.0.1 --stdin=9003 --control=9001 --hb=9000 --Session.signature_scheme="hmac-sha256" --Session.key=b"4242ce19-63a3-4f21-b03d-a18253985f34" --shell=9002 --transport="tcp" --iopub=9004 --f=~/Library/Jupyter/runtime/kernel-v2-39151QkBNnXn71tW9.json
> cwd: ~/prj/ovito-pro/tests/scripts
10:28:00.446 [info] ipykernel version & path 6.25.1, ~/miniconda3/envs/jupyter/lib/python3.11/site-packages/ipykernel/__init__.py for ~/miniconda3/envs/jupyter/bin/python
10:28:00.785 [warn] StdErr from Kernel Process 0.00s - Debugger warning: It seems that frozen modules are being used, which may
0.00s - make the debugger miss breakpoints. Please pass -Xfrozen_modules=off
0.00s - to python to disable frozen modules.
0.00s - Note: Debugging will proceed. Set PYDEVD_DISABLE_FILE_VALIDATION=1 to disable this validation.
10:28:00.870 [warn] StdErr from Kernel Process ~/.local/lib/python3.11/site-packages/traitlets/traitlets.py:2548: FutureWarning: Supporting extra quotes around strings is deprecated in traitlets 5.0. You can use 'hmac-sha256' instead of '"hmac-sha256"' if you require traitlets >=5.
warn(
10:28:00.870 [warn] StdErr from Kernel Process ~/.local/lib/python3.11/site-packages/traitlets/traitlets.py:2499: FutureWarning: Supporting extra quotes around Bytes is deprecated in traitlets 5.0. Use '4242ce19-63a3-4f21-b03d-a18253985f34' instead of 'b"4242ce19-63a3-4f21-b03d-a18253985f34"'.
warn(
10:28:00.997 [info] Started Kernel jupyter (Python 3.10.6) (pid: 40407)
10:28:00.997 [info] Started new session 5e91cf1b-3873-4fd6-875d-ce2ccff607b2
10:28:02.245 [info] Handle Execution of Cells 0 for ~/prj/ovito-pro/tests/scripts/Untitled.ipynb
10:28:02.249 [info] Kernel acknowledged execution of cell 0 @ 1692001682247
10:28:02.516 [info] End refreshing Kernel Picker (1692001680102)
10:28:02.884 [info] End cell 0 execution @ 1692001682883, started @ 1692001682247, elapsed time = 0.636s
You may want to compare this to the output you see on your system.
Another thing I did in the meantime is pushing the latest version 0.1.5 of the JavaScript jupyter-ovito package module to the npm repo (replacing the outdated version 0.1.4). It may be under certain circumenstances that VS Code’s Jupyter implementation tries to pull this package from the repo, which is needed for the frontend implementation of the 3d viewport widget. The error message suggest that this module wasn’t available for some reason, maybe because VS code could access the module’s latest version. So this update could make a difference for you if you try again. Under normal circumstance though, the module gets automatically installed as part of the ovito
conda package and no download from the npm server is necessary.