Jupyter notebook KeyError: ‘allow_remote_access’


(Nafiseh Salmaniniyasar) #1

When I call Jupyter notebook

I get error. It seems it has issue with allow remote access or some ip address that is changed via the following commands
jupyter notebook --generate-config echo “c.NotebookApp.ip = ‘*’” >> ~/.jupyter/jupyter_notebook_config.py echo “c.NotebookApp.open_browser = False” >> ~/.jupyter/jupyter_notebook_config.py pip install ipywidgets jupyter nbextension enable --py widgetsnbextension --sys-prefix

Here is the error

(fastai) paperspace@ps1r995v4:~/fastai$ jupyter notebook
[I 10:45:29.673 NotebookApp] Writing notebook server cookie secret to /run/user/1000/jupyter/notebook_cookie_secret
Traceback (most recent call last):
File “/home/paperspace/anaconda3/envs/fastai/lib/python3.6/site-packages/traitlets/traitlets.py”, line 528, in get
value = obj._trait_values[self.name]
KeyError: ‘allow_remote_access’

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/home/paperspace/anaconda3/envs/fastai/lib/python3.6/site-packages/notebook/notebookapp.py”, line 869, in _default_allow_remote
addr = ipaddress.ip_address(self.ip)
File “/home/paperspace/anaconda3/envs/fastai/lib/python3.6/ipaddress.py”, line 54, in ip_address
address)
ValueError: ‘’ does not appear to be an IPv4 or IPv6 address

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/home/paperspace/anaconda3/envs/fastai/bin/jupyter-notebook”, line 11, in
sys.exit(main())
File “/home/paperspace/anaconda3/envs/fastai/lib/python3.6/site-packages/jupyter_core/application.py”, line 266, in launch_instance
return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
File “/home/paperspace/anaconda3/envs/fastai/lib/python3.6/site-packages/traitlets/config/application.py”, line 657, in launch_instance
app.initialize(argv)
File “”, line 2, in initialize
File “/home/paperspace/anaconda3/envs/fastai/lib/python3.6/site-packages/traitlets/config/application.py”, line 87, in catch_config_error
return method(app, *args, **kwargs)
File “/home/paperspace/anaconda3/envs/fastai/lib/python3.6/site-packages/notebook/notebookapp.py”, line 1629, in initialize
self.init_webapp()
File “/home/paperspace/anaconda3/envs/fastai/lib/python3.6/site-packages/notebook/notebookapp.py”, line 1379, in init_webapp
self.jinja_environment_options,
File “/home/paperspace/anaconda3/envs/fastai/lib/python3.6/site-packages/notebook/notebookapp.py”, line 158, in init
default_url, settings_overrides, jinja_env_options)
File “/home/paperspace/anaconda3/envs/fastai/lib/python3.6/site-packages/notebook/notebookapp.py”, line 251, in init_settings
allow_remote_access=jupyter_app.allow_remote_access,
File “/home/paperspace/anaconda3/envs/fastai/lib/python3.6/site-packages/traitlets/traitlets.py”, line 556, in get
return self.get(obj, cls)
File “/home/paperspace/anaconda3/envs/fastai/lib/python3.6/site-packages/traitlets/traitlets.py”, line 535, in get
value = self._validate(obj, dynamic_default())
File “/home/paperspace/anaconda3/envs/fastai/lib/python3.6/site-packages/notebook/notebookapp.py”, line 872, in _default_allow_remote
for info in socket.getaddrinfo(self.ip, self.port, 0, socket.SOCK_STREAM):
File “/home/paperspace/anaconda3/envs/fastai/lib/python3.6/socket.py”, line 745, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -2] Name or service not known


Wiki: Lesson 1
Fastai v0.7 install issues thread
Truncated Notebooks
(Willismar Medeiros) #2

I remember this instruction :

jupyter notebook --generate-config echo “c.NotebookApp.ip = ‘*’”

where changed by notebook package in the past to be of type ‘localhost’ or a fixed IP number.

Probably more people using conda will at some point experience that error when updating packages to new versions.

Just update that key manually on file $HOME/.jupyter/jupyter_notebook_config.py

1- You can try to change c.NotebookApp.ip = ‘localhost’ and make sure that you /etc/hosts file points the name localhost to IP 127.0.0.01

2- Or you can try to change to c.NotebookApp.ip = ‘0.0.0.0’


Cannot run jupyter notebook after setup
#3

Thank you! Had the same problem, this fixed it.


(Tom Brooke) #5

I have the same error – I uncommented and changed c.NotebookApp.ip to: c.NotebookApp.ip = ‘0.0.0.0’

I still get this error:
(would the optional steps to install locally solve thie?)

Traceback (most recent call last):
File “/home/paperspace/anaconda3/envs/fastai/lib/python3.6/site-packages/traitlets/traitlets.py”, line 528, in get
value = obj._trait_values[self.name]
KeyError: ‘allow_remote_access’

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/home/paperspace/anaconda3/envs/fastai/lib/python3.6/site-packages/notebook/notebookapp.py”, line 869, in _default_allow_remote
addr = ipaddress.ip_address(self.ip)
File “/home/paperspace/anaconda3/envs/fastai/lib/python3.6/ipaddress.py”, line 54, in ip_address
address)
ValueError: ‘’ does not appear to be an IPv4 or IPv6 address


(Willismar Medeiros) #6

ValueError: ‘’ does not appear to be an IPv4 or IPv6 address

this means you don’t have a valid IP… you can try to use ‘0.0.0.0’ or ‘localhost’ on your
c.NotebookApp.ip as I mentioned earlier.


(Chris Kelley) #7

this may be a noob observation, but the command:
jupyter notebook --generate-config echo “c.NotebookApp.ip = ‘*’”

should be changed to:
jupyter notebook --generate-config jupyter_notebook_config.py “c.NotebookApp.ip = ‘127.0.0.1’”

it took me a moment to notice that if you use echo it means that the system is looking for a folder or file named echo. That was probably understood by most people reading this. After getting past that I am now getting a new problem:

(fastai) paperspace@psddgai82:~/.jupyter$ jupyter notebook
[I 18:58:29.865 NotebookApp] Writing notebook server cookie secret to /run/user/1000/jupyter/notebook_cookie_secret
[I 18:58:30.359 NotebookApp] Serving notebooks from local directory: /home/paperspace/.jupyter
[I 18:58:30.359 NotebookApp] The Jupyter Notebook is running at:
[I 18:58:30.359 NotebookApp] http://localhost:8888/?token=9d5a5aa6bd58f5e9
[I 18:58:30.359 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[W 18:58:30.359 NotebookApp] No web browser found: could not locate runnable browser.
[C 18:58:30.360 NotebookApp]

Copy/paste this URL into your browser when you connect for the first time,
to login with a token:
    http://localhost:8888/?token=9d5a5................

(Willismar Medeiros) #8

“this may be a noob observation, but the command:”

Are you following what I said earlier ? You just repeated what I said.

Anyway…

Your error is because you are in a “computer” that doesn’t have a browser installed and may be doesn’t have a GUI interface. By default if jupyter notebook is called in a computer that has GUI and a browser installed , it tries to open it asap the service it turned on. But if you in a isolated environment without any sharing GUI interface its a useless try and you can disable it.

Try this:

jupyter notebook --no-browser

Or you can hack into the jupyter_notebook_config.py to set the key:

c.NotebookApp.open_browser = False


(Gursimran Singh) #9

Noting what worked for me, as a Paperspace user following the DL1 course’s setup stuff, with an ubuntu fast.ai template machine with GPU+:

$ jupyter notebook --generate-config ~/.jupyter/jupyter_notebook_config.py "c.NotebookApp.ip = '127.0.0.1'"
Overwrite /home/paperspace/.jupyter/jupyter_notebook_config.py with default config? [y/N]y
Writing default config to: /home/paperspace/.jupyter/jupyter_notebook_config.py

Also: I couldn’t make it work by just manually editing the config file, and I didn’t have to specify “–no-browser” when launching jupyter notebok, Jupyter automatically accounted for that.

Hope that helps!


(Joshua) #10

curious what was the link in the browser that worked for you?

I am running jupyter from paperspace:
juypter notebook worked great until I pulled for updates
Tried following fixes:
*created config file by running suggested command
*copied http://localhost:8888/?token=" " doesn’t work. changed localhost to 127.0.0.1 same result.
last tried my given ip and same result
I tried editing config file with no success thus far. I might just try starting from scratch with a new machine.


(Joshua) #11

Success running: jupyter notebook --ip=‘0.0.0.0’

  1. copied link and entered paperspace id:
    http://enter paperspace ip here:8888/?token=f38212e3acd43d6d5353300a019d166f378f4d5ccb384ba1link

  2. run link in browser


(Gursimran Singh) #12

@jjwurd I followed the suggested setup instructions: https://github.com/reshamas/fastai_deeplearn_part1/blob/master/tools/paperspace.md. Note that at the bottom, there’s a suggested ssh config that allows you to both open a terminal and also forward port 8888 from your local computer to the paperspace virtual computer by just running ssh paperspace. With this as an assumption, the link Jupyter says (with ‘localhost’ in it) will work as-is – because the service is actually tunneled in from the remote computer to your local one as if it was running on your computer.


(Nikita) #13

The most useful comment. Thank you very much!


#14

I managed to fix the error and get access to my notebook remotely (without ssh tunnelling) by editing the config file at ~/.jupyter/jupyter_notebook_config.py with the following changes:

  • uncomment and set c.NotebookApp.ip = '0.0.0.0'
  • uncomment and set c.NotebookApp.allow_remote_access = '*'

Fastai v1 install issues thread
(Yin Huang) #15

Thanks, it worked.


(Kenneth Reid) #16

Thank you Willismar,
I have been stuggling with this for a while. I did not understand an answer to a simuliar question but this post was very clear.


(Stavros Langousis) #17

Thanks, I set c.NotebookApp.allow_remote_access = True


(nok) #18

Thanks! This puzzle me a lot and causing issue in every environment since this config is not under conda env.