Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jupyter run notebook.ipynb does not work #7025

Closed
charmoniumQ opened this issue Aug 30, 2023 · 5 comments
Closed

jupyter run notebook.ipynb does not work #7025

charmoniumQ opened this issue Aug 30, 2023 · 5 comments
Labels
bug status:Needs Triage Applied to issues that need triage

Comments

@charmoniumQ
Copy link

charmoniumQ commented Aug 30, 2023

Description

Docs say that jupyter run notebook.ipynb will execute the notebook. It appears that Jupyter is instead trying to evaluate the JSON contents of notebook.ipynb. In more complex notebooks, I will get "true" is not defined or "null" is not defined on a specific line of the notebook which contains JSON true or null.

Reproduce

Source code
{"cells": [{"cell_type": "code",
   "execution_count": 1,
   "id": "d3baff75-e7bf-46f3-9ede-b5c0f725123f",
   "metadata": {},
   "outputs": [{"name": "stdout",
     "output_type": "stream",
     "text": ["hello world\n"]}],
   "source": ["import pathlib; pathlib.Path('test').write_text('world')"]}],
 "metadata": {"kernelspec": {"display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"},
  "language_info": {"codemirror_mode": {"name": "ipython", "version": 3},
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.4"}},
 "nbformat": 4,
 "nbformat_minor": 5}
  1. Write a very simple notebook named notebook.ipynb which writes a file called hello.
  2. pip install notebook
  3. jupyter run notebook.ipynb
  4. ls -l and see that hello does not exist.

Jupyter did not actually execute the notebook. In notebooks with null execution counts, I will git "null" is not defined on that line, which seems to indicate that jupyter is simply evaluating the file as a Python expression (which it is not).

Expected behavior

jupyter run notebook.ipynb should actually execute the notebook or change the documentation to not advertise this functionality.

Context

  • Operating System and version: Ubuntu 22.04
  • Browser and version: N/A
$ jupyter --version         
Selected Jupyter core packages...
IPython          : 8.14.0
ipykernel        : 6.25.1
ipywidgets       : not installed
jupyter_client   : 8.3.1
jupyter_core     : 5.3.1
jupyter_server   : 2.7.2
jupyterlab       : 4.0.5
nbclient         : 0.8.0
nbconvert        : 7.8.0
nbformat         : 5.9.2
notebook         : 7.0.3
qtconsole        : not installed
traitlets        : 5.9.0
Troubleshoot Output
[notice] A new release of pip is available: 23.1.2 -> 23.2.1
[notice] To update, run: pip install --upgrade pip
$PATH:
        /home/sam/box/prov/src/test/kernels/.venv/bin
        /nix/store/11hrc3lnzp8jyb3afmmy9h4m4c30jkgs-starship-1.15.0/bin
        /home/sam/.local/share/spack/bin
        /home/sam/.nix-profile/bin
        /nix/var/nix/profiles/default/bin
        /home/sam/.local/share/cargo/bin
        /usr/local/sbin
        /usr/local/bin
        /usr/sbin
        /usr/bin
        /sbin
        /bin
        /usr/games
        /usr/local/games
        /snap/bin
        /home/sam/.local/bin

sys.path:
/home/sam/box/prov/src/test/kernels/.venv/bin
/nix/store/xlpbkwgf4nrnr56a3r0k0r32jxlxyf59-python3-3.11.4/lib/python311.zip
/nix/store/xlpbkwgf4nrnr56a3r0k0r32jxlxyf59-python3-3.11.4/lib/python3.11
/nix/store/xlpbkwgf4nrnr56a3r0k0r32jxlxyf59-python3-3.11.4/lib/python3.11/lib-dynload
/home/sam/box/prov/src/test/kernels/.venv/lib/python3.11/site-packages

sys.executable:
/home/sam/box/prov/src/test/kernels/.venv/bin/python

sys.version:
3.11.4 (main, Jun 6 2023, 22:16:46) [GCC 12.3.0]

platform.platform():
Linux-5.15.0-79-generic-x86_64-with-glibc2.37

which -a jupyter:
/home/sam/box/prov/src/test/kernels/.venv/bin/jupyter

pip list:
Package Version
------------------------- -----------
anyio 3.7.1
argon2-cffi 23.1.0
argon2-cffi-bindings 21.2.0
arrow 1.2.3
asttokens 2.2.1
async-lru 2.0.4
attrs 23.1.0
Babel 2.12.1
backcall 0.2.0
beautifulsoup4 4.12.2
bleach 6.0.0
certifi 2023.7.22
cffi 1.15.1
charset-normalizer 3.2.0
comm 0.1.4
debugpy 1.6.7.post1
decorator 5.1.1
defusedxml 0.7.1
executing 1.2.0
fastjsonschema 2.18.0
fqdn 1.5.1
idna 3.4
ipykernel 6.25.1
ipython 8.14.0
isoduration 20.11.0
jedi 0.19.0
Jinja2 3.1.2
json5 0.9.14
jsonpointer 2.4
jsonschema 4.19.0
jsonschema-specifications 2023.7.1
jupyter_client 8.3.1
jupyter_core 5.3.1
jupyter-events 0.7.0
jupyter-lsp 2.2.0
jupyter_server 2.7.2
jupyter_server_terminals 0.4.4
jupyterlab 4.0.5
jupyterlab-pygments 0.2.2
jupyterlab_server 2.24.0
MarkupSafe 2.1.3
matplotlib-inline 0.1.6
mistune 3.0.1
nbclient 0.8.0
nbconvert 7.8.0
nbformat 5.9.2
nest-asyncio 1.5.7
notebook 7.0.3
notebook_shim 0.2.3
overrides 7.4.0
packaging 23.1
pandocfilters 1.5.0
parso 0.8.3
pexpect 4.8.0
pickleshare 0.7.5
pip 23.1.2
platformdirs 3.10.0
prometheus-client 0.17.1
prompt-toolkit 3.0.39
psutil 5.9.5
ptyprocess 0.7.0
pure-eval 0.2.2
pycparser 2.21
Pygments 2.16.1
python-dateutil 2.8.2
python-json-logger 2.0.7
PyYAML 6.0.1
pyzmq 25.1.1
referencing 0.30.2
requests 2.31.0
rfc3339-validator 0.1.4
rfc3986-validator 0.1.1
rpds-py 0.10.0
Send2Trash 1.8.2
setuptools 65.5.0
six 1.16.0
sniffio 1.3.0
soupsieve 2.4.1
stack-data 0.6.2
terminado 0.17.1
tinycss2 1.2.1
tornado 6.3.3
traitlets 5.9.0
uri-template 1.3.0
urllib3 2.0.4
wcwidth 0.2.6
webcolors 1.13
webencodings 0.5.1
websocket-client 1.6.2

jupyter run --debug
jupyter run --debug Untitled.ipynb                                 
[RunApp] Searching ['/home/sam/box/prov/src/test/kernels/.venv/etc/jupyter', '/home/sam/.config/jupyter', '/usr/local/etc/jupyter', '/etc/jupyter'] for config files
[RunApp] Looking for jupyter_config in /etc/jupyter
[RunApp] Looking for jupyter_config in /usr/local/etc/jupyter
[RunApp] Looking for jupyter_config in /home/sam/.config/jupyter
[RunApp] Looking for jupyter_config in /home/sam/box/prov/src/test/kernels/.venv/etc/jupyter
[RunApp] Looking for jupyter run_config in /etc/jupyter
[RunApp] Looking for jupyter run_config in /usr/local/etc/jupyter
[RunApp] Looking for jupyter run_config in /home/sam/.config/jupyter
[RunApp] Looking for jupyter run_config in /home/sam/box/prov/src/test/kernels/.venv/etc/jupyter
[RunApp] Connection File not found: /home/sam/.local/share/jupyter/runtime/kernel-2385632.json
0.00s - Debugger warning: It seems that frozen modules are being used, which may
0.00s - make the debugger miss breakpoints. Please pass -Xfrozen_modules=off
0.00s - to python to disable frozen modules.
0.00s - Note: Debugging will proceed. Set PYDEVD_DISABLE_FILE_VALIDATION=1 to disable this validation.
[RunApp] Instantiating kernel 'Python 3 (ipykernel)' with kernel provisioner: local-provisioner
[RunApp] Starting kernel: ['/home/sam/box/prov/src/test/kernels/.venv/bin/python', '-m', 'ipykernel_launcher', '-f', '/home/sam/.local/share/jupyter/runtime/kernel-2385632.json', 'Untitled.ipynb']
[RunApp] Connecting to: tcp://127.0.0.1:34447
[RunApp] connecting iopub channel to tcp://127.0.0.1:50623
[RunApp] Connecting to: tcp://127.0.0.1:50623
[RunApp] connecting shell channel to tcp://127.0.0.1:43263
[RunApp] Connecting to: tcp://127.0.0.1:43263
[RunApp] connecting stdin channel to tcp://127.0.0.1:51469
[RunApp] Connecting to: tcp://127.0.0.1:51469
[RunApp] connecting heartbeat channel to tcp://127.0.0.1:40461
[RunApp] connecting control channel to tcp://127.0.0.1:34447
[RunApp] Connecting to: tcp://127.0.0.1:34447
0.00s - Debugger warning: It seems that frozen modules are being used, which may
0.00s - make the debugger miss breakpoints. Please pass -Xfrozen_modules=off
0.00s - to python to disable frozen modules.
0.00s - Note: Debugging will proceed. Set PYDEVD_DISABLE_FILE_VALIDATION=1 to disable this validation.
[RunApp] jupyter run: starting...
[RunApp] jupyter run: executing `Untitled.ipynb`
{'cells': [{'cell_type': 'code',
   'execution_count': 1,
   'id': 'd3baff75-e7bf-46f3-9ede-b5c0f725123f',
   'metadata': {},
   'outputs': [{'name': 'stdout',
     'output_type': 'stream',
     'text': ['hello world\n']}],
   'source': ["import pathlib; pathlib.Path('test').write_text('world')"]}],
 'metadata': {'kernelspec': {'display_name': 'Python 3 (ipykernel)',
   'language': 'python',
   'name': 'python3'},
  'language_info': {'codemirror_mode': {'name': 'ipython', 'version': 3},
   'file_extension': '.py',
   'mimetype': 'text/x-python',
   'name': 'python',
   'nbconvert_exporter': 'python',
   'pygments_lexer': 'ipython3',
   'version': '3.11.4'}},
 'nbformat': 4,
 'nbformat_minor': 5}
@charmoniumQ charmoniumQ added bug status:Needs Triage Applied to issues that need triage labels Aug 30, 2023
@jtpio
Copy link
Member

jtpio commented Sep 4, 2023

Thanks @charmoniumQ for opening the issue.

Looks like this command might be coming from the nbclient sub-project? Maybe it would make sense to open the issue there instead: https://github.com/jupyter/nbclient/

@jtpio
Copy link
Member

jtpio commented Sep 4, 2023

Actually nbclient provides the jupyter execute sub-command: https://github.com/jupyter/nbclient/blob/dcfdde2073f652e3811e00b70190f0c1dc3494c7/pyproject.toml#L72

Maybe the docs on https://github.com/jupyter/jupyter should also be updated.

@charmoniumQ
Copy link
Author

So the docs should say jupyter execute instead of jupyter run?

@JasonWeill
Copy link
Collaborator

Yes, they should. @palewire made the change from execute to run in November 2021, but this change should be reverted because the commands are different: jupyter/jupyter@7929d9c

@RRosio
Copy link
Collaborator

RRosio commented Sep 5, 2023

Closing this issue in favor of the issue above which in the Jupyter pository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug status:Needs Triage Applied to issues that need triage
Projects
None yet
Development

No branches or pull requests

4 participants