Closed stefaneidelloth closed 2 years ago
Thanks for reporting this issue! The error is caused by this line
which deactivates in-cell scrolling when working in Jupyter notebooks. Jupyterlab-notebooks don't have in-cell scrolling anyway. Not sure why the try-except-block doesn't work here...
A quick-fix would be to remove these 6 lines locally, in your installation.
About a longer-term fix: @gidden introduced this specification for Jupyter-notebooks, so I'd defer to him about whether to simply remove it. Not sure if there is a good way to check whether a user is working Jupyter notebooks or Jupyterlab-notebooks...
JupyterLab does not provide the global IPython variable in JavaScript.
Not sure if there is a good way to check whether a user is working Jupyter notebooks or Jupyterlab-notebooks
def in_ipynb():
try:
cfg = get_ipython().config
if cfg['IPKernelApp']['parent_appname'] == 'ipython-notebook':
return True
else:
return False
except NameError:
return False
Seems that this discussion is outdated.
Just tried this, when I run get_ipython().config['IPKernelApp']
, the only attribute in the dictionary is a connection_file
, and there seem to be no relevant info in that file for distinguishing between Jupyter and Jupyter-lab...
Verified that the check does not work any more. As an alternative to checking JupyterLab vs Notebook, here is a check in Javascript:
shell.run_cell_magic(
u"javascript",
u"",
u"if (typeof IPython !== 'undefined') { IPython.OutputArea.prototype._should_scroll = function(lines) { return false; }}",
)
If I import pyam in JupyterLab 3.2.3 on Windows I get the warning
Javascript Error: IPython is not defined
=> How to avoid that?