I am creating a jupyter notebook
programatically with Python. Using the nbformat
library.
Once I create the file:
fname = f'{filename}.ipynb'
with open(fname, 'w') as notebook:
nbf.write(nb, notebook)
I open the file with Jupyter Lab and get the following error in the terminal console:
Fatal Python error: init_import_size: Failed to import the site module
Python runtime state: initialized
Traceback (most recent call last):
File "/Users/sota/anaconda3/lib/python3.8/site.py", line 580, in <module>
main()
File "/Users/sota/anaconda3/lib/python3.8/site.py", line 567, in main
known_paths = addsitepackages(known_paths)
File "/Users/sota/anaconda3/lib/python3.8/site.py", line 350, in addsitepackages
addsitedir(sitedir, known_paths)
File "/Users/sota/anaconda3/lib/python3.8/site.py", line 208, in addsitedir
addpackage(sitedir, name, known_paths)
File "/Users/sota/anaconda3/lib/python3.8/site.py", line 169, in addpackage
exec(line)
File "<string>", line 1, in <module>
File "/Users/sota/anaconda3/lib/python3.8/importlib/util.py", line 14, in <module>
from contextlib import contextmanager
File "/Users/sota/anaconda3/lib/python3.8/contextlib.py", line 5, in <module>
from collections import deque
File "/Users/sota/anaconda3/lib/python3.8/collections/__init__.py", line 24, in <module>
import heapq as _heapq
File "/Users/sota/anaconda3/lib/python3.8/heapq.py", line 581, in <module>
from _heapq import *
KeyboardInterrupt
I have been researching a lot, but I don't get to find the error... some guidance on why this is happening?
PD: the only solution I've found so far is openinig the notebook
with vscode
and somehow, the notebook gets fixed.