The main problem, I believe, is that you are trying to relate something running inside your web browser via web assembly (WASM) to typical, full Python running on a remote machine. JupyterLite and the WASM based kernel (pyodide-baed) is still very much in development and doesn’t have all the abilities a typical, full Python kernel does.
If you want a online Jupyter Notebooks/JupyterLab typical full Python kernel, go here and click on the ‘launch binder
’ badge. Your session that will spin up will be a temporary remote session running on a remote linux machine. (Launches though have been a little rocky since Google stopped being a member of the Binder federation.) Make sure to save back to your local computer anything useful you make. You can switch from JupyterLab to the classic interface under the ‘Help’ menu along the top of the JupyterLab window.
The session you get from the process I describe above will be basic much like your Google Colab system. It won’t have Pytorch already installed. You can launch a session served via the MyBinder service with Pytorch already installed by going here and using the ‘launch binder
’ badge way at the bottom.
Always share direct links in your posts.
And pay attention to the exact nature of the kernels indicated in the upper right corner.
I suspect your online Jupyter Notebooks are based on pyodide whereas the Google Colab is using a typical full, Python kernel running on a remote linux system. However, because you don’t provide links, I cannot for sure support this guess. The errors are indicative though.
And the issue is just as reported back to you when you attempt. Running %pip install pytorch
in a cell in your notebook is telling you that it needs pure Python 3 wheel because web assembly cannot use stuff that isn’t pure Python at this time. The Google Colab instance can use Python integrated with C code.
Note: Be careful about some of your other false equivalencies. Google Colab uses a highly modified branch of an outdated version of Jupyter Notebooks.
This is why it doesn’t have the magic install commands that you should be using in modern Jupyter. Don’t use the exclamation point with install commands in modern Jupyter. Google Colab is the exception because in a lot of ways it is outdated and not modern.
Due to a lot of work by the developers, the same magic install commands for pip now work in both the typical, full Python kernels running in modern Jupyter or the Pyodide-based WASM kernels running in JupyterLite. If Google Colab wasn’t hanging on to using an outdated fork, it would be easy to state to always use the magic install commands in Jupyter everywhere without any caveat.