Inner navigation links with anchors

Greetings,

Thanks for reading. I have a jupyter notebook that uses inner navigation links using anchors. These links were working beautifully up until I had to change my machine and I installed Anaconda. Now, the links do not work (the code itself seems to be running fine) and I get the following messages:

[IPKernelApp] ERROR | Failed to open SQLite history C:\Users\luisj.ipython\profile_default\history.sqlite (datatype mismatch).
[IPKernelApp] ERROR | Exception in message handler:
Traceback (most recent call last):
File “C:\Users\luisj\anaconda3\Lib\site-packages\IPython\core\history.py”, line 78, in catch_corrupt_db
return f(self, *a, **kw)
^^^^^^^^^^^^^^^^^
File “C:\Users\luisj\anaconda3\Lib\site-packages\IPython\core\history.py”, line 684, in get_tail
self._run_sql(
File “C:\Users\luisj\anaconda3\Lib\site-packages\IPython\core\history.py”, line 304, in _run_sql
cur = self.db.execute(this_querry, params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
sqlite3.IntegrityError: datatype mismatch

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “C:\Users\luisj\anaconda3\Lib\site-packages\ipykernel\kernelbase.py”, line 437, in dispatch_shell
await result
File “C:\Users\luisj\anaconda3\Lib\site-packages\ipykernel\kernelbase.py”, line 876, in history_request
reply_content = self.do_history(**content)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\luisj\anaconda3\Lib\site-packages\ipykernel\ipkernel.py”, line 619, in do_history
hist = self.shell.history_manager.get_tail(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\luisj\anaconda3\Lib\site-packages\decorator.py”, line 232, in fun
return caller(func, *(extras + args), **kw)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\luisj\anaconda3\Lib\site-packages\IPython\core\history.py”, line 105, in catch_corrupt_db
self.hist_file.rename(newpath)
File “C:\Users\luisj\anaconda3\Lib\pathlib.py”, line 1363, in rename
os.rename(self, target)
PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: ‘C:\Users\luisj\.ipython\profile_default\history.sqlite’ → ‘C:\Users\luisj\.ipython\profile_default\history-corrupt-2025-02-12T10.25.30.398226.sqlite’

I’ve tried deleting the history file, checking for corrupted files, updating jupyter, dowgrading jupyter, … etc. Following a suggestion online, I installed jupyter_contrib_nbextensions and, while the error message disappeared, the links still do not work.

Any guidance would be appreciated.

Thanks,

Luis

When you say, “I had to change my machine”. Does this mean your current system was completely new and didn’t have Anaconda or Python or Jupyter in the past?


This doesn’t address your main issue, but is probably an aside to something you bring up in your troubleshooting…

If you only installed Anaconda recently, then ‘jupyter_contrib_nbextensions’ probably isn’t relevant. That only works with the older Jupyter tech that Anaconda currently doesn’t include by default. (And most likely you don’t need.) You’d have to opt into it or use NbClassic for it to make sense to even try that. Beyond NbClassic, ‘jupyter_contrib_nbextensions’ are only pertinent to Jupyter Notebook 6.4 and earlier versions.

Thanks! I installed Anaconda on a brand new machine. When I tried using the inner links on an old jupyter notebook using the new machine, the links did not work and I got the log that I shared.

All this happened a couple of days ago. After that I installed jupyter_contrib_nbextensions as an attempt to solve the initial issue. This was unsuccessful.

My question boils down to: are those inner links not supposed to work with the most recent versions of Anaconda and/or Jupyter? Otherwise, does anyone knows how to make the links work?

I appreciate your help!

Can you share the syntax you are using?

I just tested some variations on one I see posted in quite a few places (using HTML <a id=..) in JupyterLab 4.3.5 and it didn’t work; however, section titles still work as anchors, like here.

Note that experimental linking by cell by an identifier is supposed to work, too. See JupyterLab’s documentation on ’ Linking Notebook Sections’ Current Jupyter Notebook is built on JupyterLab components, and so I think it holds for there, too. There is a caveat though:

" The cell-id fragment locator is not part of a formal Jupyter standard and subject to change."


Note that if you ever need an independent place to test with current Jupyter, there is typically an easy way without messing around on your machine:

For checking with current Jupyter:

See here for what I think the latest announcement of the project. (Related to this topic of navigating in the notebook, note there is the new ‘Minimap’.)

If you click the first link there on that announcement that says ’ JupyterLab 4.3.’ and go to the JupyterLab repo page you’ll see a ‘launch binder’ badge that will bring up a session with JupyterLab 4.3.5 at present. You can try that there and see. (Or just click here to launch such a session directly.)

Similarly, if you follow the second link there to the Jupyter Notebook repo page, there is a ‘launch binder’ badge there that will give you a session with Jupyter Notebook version 7.4.0a3 at present. (Alternatively, click here to directly launch such a session with current Jupyter Notebook coming up upon launch.)

Thank you so very much for your thorough response. The image below provides an example of the syntax I am using.

Okay, I see that is the id method.
In my tests right now that isn’t working. It seems in 2022 that worked as it is mentioned in the very first sentence of the issue post that caveat references here at the top of ’ Fragment Identification Syntax for Jupyter (linking to cells in document).
So maybe I’m just not using the correct syntax to test. Yet, it not being brought up in the JupyterLab documentation on linking has me wondering.

I see. OK, it’s good to know that it isn’t a problem with my install.

Is there an approach you would suggest to have links to cells?

It depends on how soon you need it working? You may want to wait until someone points out how to get the id approach working again before changing everything? I would feel better about suggesting that if I could find the issue post about this, if there is one. (But maybe there isn’t one because the documentation only mentions two ways and id tag isn’t one of them?)

The two ways in the documentation at this time are the only ways to do it, as it would seem.

Not very urgent. Again, thanks for your help!

1 Like