hhu-stups / prolog-jupyter-kernel

A Jupyter kernel for Prolog
MIT License
17 stars 3 forks source link

Auto-generating the `kernel.json` file breaks starting the kernel #14

Closed pmoura closed 1 year ago

pmoura commented 1 year ago

The https://github.com/hhu-stups/prolog-jupyter-kernel/commit/ad3f209a6ca478c635d3a048bcfa93280933fe4e change breaks the Prolog kernel for me. Same when I back-ported it to the Logtalk kernel. I get:

/opt/local/bin/python3.10: No module named prolog_kernel
[I 2022-12-02 15:27:23.886 ServerApp] AsyncIOLoopKernelRestarter: restarting kernel (1/5), new random ports
/opt/local/bin/python3.10: No module named prolog_kernel
[I 2022-12-02 15:27:26.903 ServerApp] AsyncIOLoopKernelRestarter: restarting kernel (2/5), new random ports
/opt/local/bin/python3.10: No module named prolog_kernel
[I 2022-12-02 15:27:29.921 ServerApp] AsyncIOLoopKernelRestarter: restarting kernel (3/5), new random ports
/opt/local/bin/python3.10: No module named prolog_kernel
[I 2022-12-02 15:27:32.938 ServerApp] AsyncIOLoopKernelRestarter: restarting kernel (4/5), new random ports
/opt/local/bin/python3.10: No module named prolog_kernel
[I 2022-12-02 15:27:35.955 ServerApp] AsyncIOLoopKernelRestarter: restarting kernel (5/5), new random ports
/opt/local/bin/python3.10: No module named prolog_kernel
...

This after uninstalling the previous version of the kernel and installing the new one:

$ pip3 uninstall prolog_kernel
$ pip3 install -e .
$ python3 -m prolog_kernel.install

I'm running:

dgelessus commented 1 year ago

My guess would be that you have mismatched Python installations in your PATH, i. e. the pip3 command comes from a different Python installation than the python3 command. It's recommended to always use python3 -m pip (change the python3 part as needed) so that you know for sure that pip is operating on the Python installation that you expect.

So in this case I'd recommend:

$ jupyter kernelspec remove prolog_kernel
$ jupyter kernelspec remove prolog_kernel
$ pip3 uninstall prolog_kernel
$ pip3 uninstall prolog_kernel
$ python3 -m pip uninstall prolog_kernel
$ python3 -m pip uninstall prolog_kernel
$ python3 -m pip install -e .
$ python3 -m prolog_kernel.install

Sometimes you need to run the uninstall commands more than once, if you have the package installed in multiple locations used by the same Python environment (e. g. user-local and system-wide).

dgelessus commented 1 year ago

I also just pushed a few changes for better feedback when installing the kernel (5b2f5af98b23fc1bf1f50090e02814746770bf68) and a better default install location (2ac5ace9e98100b3a579fce2b23dc9d8b3645436). These should help with debugging the issue.

pmoura commented 1 year ago

Thanks for the quick reply. That sequence of shell commands solved the problem for both kernels (although, interestingly, only a single installation for each kernel was found by the uninstall commands).

pmoura commented 1 year ago

I also just pushed a few changes for better feedback when installing the kernel (5b2f5af) and a better default install location (2ac5ace). These should help with debugging the issue.

Thanks. I applied those changes to the Logtalk kernel (https://github.com/LogtalkDotOrg/logtalk-jupyter-kernel/commit/1c968deabaace9d15c8a2ed1b7c6f17915d2c52d).