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

CommandError: Could not load shell runner: 'IPython Notebook'. #1835

Open
flo-85 opened this issue Aug 24, 2023 · 8 comments
Open

CommandError: Could not load shell runner: 'IPython Notebook'. #1835

flo-85 opened this issue Aug 24, 2023 · 8 comments

Comments

@flo-85
Copy link

flo-85 commented Aug 24, 2023

I am using django 4.2 abd python 3.10.
OS: Windows WSL (Linux subsystem on a windows machine)

This works:

./manage.py shell_plus --ipython

But not this:

./manage.py shell_plus --notebook

Error:

Traceback (most recent call last):
  File "/home/florent/github/web_api/.venv/lib/python3.10/site-packages/django_extensions/management/commands/shell_plus.py", line 281, in get_notebook
    from notebook.notebookapp import NotebookApp
ModuleNotFoundError: No module named 'notebook.notebookapp'

CommandError: Could not load shell runner: 'IPython Notebook'.

pip list:

ipython                           8.14.0
ipython-genutils                  0.2.0
jupyter                           1.0.0
jupyter_client                    8.3.0
jupyter-console                   6.6.3
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
jupyterlab-widgets
@slyapustin
Copy link

I was able to temporarily fix that by using old version of jupyter_client:

jupyter_client==7.4.8

@aa403
Copy link

aa403 commented Sep 4, 2023

also getting this issue, and it continues to present after downgrading jupyer_client ... I have the following:

ipython==8.15.0
ipython-genutils==0.2.0
  
jupyter==1.0.0
jupyter-console==6.6.3
jupyter-events==0.7.0
jupyter-lsp==2.2.0
jupyter_client==7.4.8  # downgraded from 8.3.1
jupyter_core==5.3.1
jupyter_server==2.7.3
jupyter_server_terminals==0.4.4
jupyterlab==4.0.5
jupyterlab-pygments==0.2.2
jupyterlab-widgets==3.0.8
jupyterlab_server==2.24.0


notebook==7.0.3  # it looks like the issue is here??
notebook_shim==0.2.3

is this an issue with a notebook release?

running on Mac M1 Pro

@chbroecker
Copy link

chbroecker commented Sep 4, 2023

I believe the issue is due to changes made in the recent quite large notebook version change from 6 to 7 and the accompanied API changes. More can be found here: https://jupyter-notebook.readthedocs.io/en/latest/migrate_to_notebook7.html

./manage.py shell_plus --lab should also still work if jupyterlab is installed.

@aa403
Copy link

aa403 commented Sep 4, 2023

yes, --lab does work ... but its quite a jump -- this django-extensions should be updated for it, no?

@lorpacini
Copy link

I confirm what @chbroecker said. For me, it worked (keeping notebook version 6) using

notebook = "==6.5.4"
nbclassic = "*"

@clax70rm
Copy link

I solved the issue downgrading notebook with this command

pip install notebook==6.5.6

Then using the command

python manage.py shell_plus --notebook

work well for me.

@hipertracker
Copy link

hipertracker commented Oct 23, 2023

PyCharm or VSCode can use Notebook 7 out of the box. For Django, I only need to set the project settings. This is a shame Notebook 7 cannot run from the terminal (it should open a browser)

import os

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'myproject.settings')
os.environ["DJANGO_ALLOW_ASYNC_UNSAFE"] = "true"

@hipertracker
Copy link

hipertracker commented Oct 23, 2023

There is a workaround. Instead of running ./manage.py shell_plus --notebook, you can run jupyter-lab command. It will open a new browser window. Now, to get access to Django context.

# First run:

import os, sys
import django

PROJECTPATH = '/path/to/your/djangoproject'
sys.path.insert(0, PROJECTPATH)
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "djangoproject.settings")
os.environ["DJANGO_ALLOW_ASYNC_UNSAFE"] = "true"
os.chdir(PROJECTPATH)
django.setup()

# and now you can run any of your code, e.g.

from django.conf import settings
print(settings.DATABASES)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants