Can not open jupyter with bench command

I have run

bench jupyter

Traceback (most recent call last):
File “/usr/lib/python3.5/runpy.py”, line 184, in _run_module_as_main
main”, mod_spec)
File “/usr/lib/python3.5/runpy.py”, line 85, in _run_code
exec(code, run_globals)
File “/home/naib/workspace/project/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 97, in
main()
File “/home/naib/workspace/project/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 18, in main
click.Group(commands=commands)(prog_name=‘bench’)
File “/home/naib/workspace/project/frappe/frappe-bench/env/lib/python3.5/site-packages/click/core.py”, line 764, in call
return self.main(*args, **kwargs)
File “/home/naib/workspace/project/frappe/frappe-bench/env/lib/python3.5/site-packages/click/core.py”, line 717, in main
rv = self.invoke(ctx)
File “/home/naib/workspace/project/frappe/frappe-bench/env/lib/python3.5/site-packages/click/core.py”, line 1137, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/home/naib/workspace/project/frappe/frappe-bench/env/lib/python3.5/site-packages/click/core.py”, line 1137, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/home/naib/workspace/project/frappe/frappe-bench/env/lib/python3.5/site-packages/click/core.py”, line 956, in invoke
return ctx.invoke(self.callback, **ctx.params)
File “/home/naib/workspace/project/frappe/frappe-bench/env/lib/python3.5/site-packages/click/core.py”, line 555, in invoke
return callback(*args, **kwargs)
File “/home/naib/workspace/project/frappe/frappe-bench/env/lib/python3.5/site-packages/click/decorators.py”, line 17, in new_func
return f(get_current_context(), *args, **kwargs)
File “/home/naib/workspace/project/frappe/frappe-bench/apps/frappe/frappe/commands/init.py”, line 25, in _func
ret = f(frappe._dict(ctx.obj), *args, **kwargs)
File “/home/naib/workspace/project/frappe/frappe-bench/apps/frappe/frappe/commands/utils.py”, line 400, in jupyter
main([‘install’, ‘jupyter’])
TypeError: ‘module’ object is not callable

1 Like

Having exactly the same problem, it was running fine previously!
I found a workaround for the moment:

Run from frappe-bench folder:

sudo apt install jupyter-notebook
sudo pip install jupyter

Now, I followed these directions:
[5 easy steps to start editing python notebooks over SSH - Willem's Fizzy Logic](http://Edit jupyter notebooks over SSH)

  1. From frappe-bench, run this:
    jupyter notebook --no-browser --port=8080
    You will get something like this:
[I 04:44:18.288 NotebookApp] Serving notebooks from local directory: /home/[frappe-user]/frappe-bench
[I 04:44:18.288 NotebookApp] The Jupyter Notebook is running at:
[I 04:44:18.289 NotebookApp] http://localhost:8080/?token=8b135cdc3344d6a46a70384848425d87a0c77d04f8a9c9e3
  1. Then, in another terminal tab, create an SSH tunnel with the safety of no commands to be run from terminal:
ssh -N -L 8080:localhost:8080 <remote_user>@<remote_host>

Do not close the terminal until done!

  1. Now, copy the URL shown by the output on the first command and paste into your browser:
http://localhost:8080/?token=8b135cdc3344d6a46a70384848425d87a0c77d04f8a9c9e3

Now, I only managed to get it running from within the apps folder.
Make sure you import module by module.

If you have a custom app, my_app, and have a python file:

/frappe-bench/apps/my_app/my_app/hello.py

And inside of this you have a function:

def hello_world():
   text = 'Hello world text'
   return text

You can import the function within Jupyter with:

from my_app.my_app.hello import hello_world

You can then run directly with:

hello_world()

You will get:

Out[5]: 'Hello world text'

Now you can run the rest of your functions properly. However, I have problems connecting to my site!

More on this here:

2 Likes