kleinee/jns

[Errno 13] Permission denied:

Closed this issue · 17 comments

Hi, I have followed the install as described, but receive the following error on issuing 'jupyter notebook'

File "/usr/local/lib/python3.6/os.py", line 220, in makedirs mkdir(name, mode) PermissionError: [Errno 13] Permission denied: '/run/user/1000/jupyter'

Hi Rob,

(un)fortunately I have not come across this issue. Please check jupyter/notebook#1318. It appears to describe what you are seeing.

  • export XDG_RUNTIME_DIR /run/user/1000/jupyter reproduces your error
  • unset XDG_RUNTIME_DIR seems to solve the issue

Eckhard

Hi Eckhard, unset XDG_RUNTIME_DIR fixed the issue.
I can now work on the jupyter notebook on my Pi, but when I try to connect from my mac with 192.168.0.7:8888 I receive a warning from Chrome 'site cant be reached', am I using correctly?
Thanks
Robin

Hi Robin,

Thanks for your feedback. I just tried using Chrome on a Mac and on first attempt got the same warning. On second attempt it worked fine. So if 192.168.0.7 is the IP address that you used to access the Pi via ssh and the server is running it should work. Did you try Safari?

Eckhard

Hi Eckhard, unfortunately neither Safari or Firefox can get access either.
Robin

Hi Robin,
Sad to hear that something went wrong. I installed from scratch via SSH from a Mac using Rasbian Jessie Lite. You might have taken a different route because you mention that you can use Jupyter on the Pi - I cannot. I just start the server on the Pi with jupyter notebook and then access it from a machine on the network with a web browser.

  • can you ping the Pi from the Mac i.e. ping 192.168.0.7?
  • if you use Network Utility on the Mac to scan the Pi for open ports what do you get?
  • If I scan the Pi after starting the server on the Pi using jupyter notebook I get:
    Open TCP Port: 22 ssh
    Open TCP Port: 8888 ddi-tcp-1

Eckhard

You may also want to look at: http://laserplasma.ninja/2015/10/16/jupyter-ipython-notebook-on-a-remote-server-tldr/ Here the last paragraph is interesting - I did not know this was possible:

  • ssh jns@192.168.0.7 -L127.0.0.1:3129:127.0.0.1:8888
  • then start the jupyter server on the Pi with jupyter notebook
  • In a browser on the Mac use localhost:3129 to access the server

Hi Robin,
Did you get it to work and if so, can you share what was wrong? Thanks. Eckhard

HI Eckhart, after starting jupyter notebook on the Pi I get on Network Utility on my mac:

Port Scan has started…

Port Scanning host: 192.168.0.7

 Open TCP Port: 	22     		ssh
 Open TCP Port: 	548    		afpovertcp
 Open TCP Port: 	5800
 Open TCP Port: 	5900   		rfb
 Open TCP Port: 	8000   		irdmi
 Open TCP Port: 	8123

Port Scan has completed…

Onto your second message, when I do:

ssh jns@192.168.0.7 -L127.0.0.1:3129:127.0.0.1:8888
then start the jupyter server on the Pi with jupyter notebook

I get:

image

I am not sure what the password is, and the token presented on the Pi does not appear to work.

image

image

Robin, thanks for the feedback.

  • I suspect that you forgot to run configure_jupyter.sh during setup
  • Logged in as user jns on the Pi you can do this now
  • As the name of the file suggests the script pre-configures the server
  • I used password authentication for my setup whereas token based authentication was introduced as default with notebook version 4.3.0 - I will look into this later
  • Once done, start the server as usual by running jupyter notebook
  • You will notice that the browser on the host is no longer opened automatically
  • You should now be able to access the server from the Mac using http://192.168.0.7:8888 and password jns
  • you may have to change the server port in your setup - look for the line c.NotebookApp.port = 8888 in the configuration file which is located in /home/jns/.jupyter/jupyter_notebook_config.py

Best of luck

Eckhard

Just came across http://blog.jupyter.org/2016/12/21/jupyter-notebook-4-3-1/ explaining the concept of token-based authentication better than I ever could. I was not aware of this change until you sent your screenshots. Just tested it. I am rather impressed how well it works and now confident that with the link you should be able to figure out how to remotely access your server.

HI Eckhard, not sure if the script ran correctly, as I cannot access the server from Mac..?
Robin

image

image

Hi Robin,

Remote Access with Current Setup

The script did not run correctly but the server is running

  • to access the server from your Mac you need to use the ip address of the PI rather than localhost!
  • assuming that the IP is still 192.168.0.7 key http://192.168.0.7:8888/ into your browser and use token reported on the PI in the line The Jupyter Notebook is running at... for authentication.

Manual Fix

As an alternative we can fix the setup manually - we just mimic what the script should have done for us. ssh into your PI as user jns.

Create Folder for Notebooks

cd /$home
mkdir notebooks

Generate Server Configuration

jupyter notebook --generate-config

Modify Server Configuration

The original script uncomments / modifies a few lines in the configuration file:
\home\jns\.jupyter/jupyter_notebook_config.py. Open the file and edit the lines shown below:

c.NotebookApp.enable_mathjax = True
c.NotebookApp.ip ='*'
c.NotebookApp.notebook_dir = '/home/jns/notebooks'
c.NotebookApp.open_browser = False
c.NotebookApp.password = 'sha1:5815fb7ca805:f09ed218dfcc908acb3e29c3b697079fea37486a'
c.NotebookApp.port = 8888

Save the file when done. You can check that everything went as intended by running
grep "^[^#;]" /home/jns/jupyter/jupyter_notebook_config.py and comparing the output to the lines above.

You can now start the server with jupyter notebook

  • On the Mac access the server with its IP address (NOT localhost) and use the password jns for authentication.

Eckhard

HI Eckhart, sorry for the confusion, originally I tried the ip address, and localhost was my final futile attempt. Anyway following your instructions above everything is working, although I had the earlier issue and had to unset XDG_RUNTIME_DIR to fix it.

BTW will I need to add all my python dependencies for user jns? I had picamera working for user pi but get the error below as jns. I am experienced using virtual environments but here we have installed jupter as another user so I am not sure how that affects things..?
Thanks
Robin

image
image

Re the picamera, when I run from command line I get an out of memory error, could be something to do with the config?

jns@raspberrypi:~/python_work_RC $ python test_camera.py

mmal: mmal_vc_port_enable: failed to enable port vc.null_sink:in:0(OPQV): ENOSPC
mmal: mmal_port_enable: failed to enable connected port (vc.null_sink:in:0(OPQV))0x975820 (ENOSPC)
mmal: mmal_connection_enable: output port couldn't be enabled
Traceback (most recent call last):
File "test_camera.py", line 2, in
camera = picamera.PiCamera()
File "/usr/lib/python2.7/dist-packages/picamera/camera.py", line 417, in init
self._init_preview()
File "/usr/lib/python2.7/dist-packages/picamera/camera.py", line 496, in _init_preview
self, self._camera.outputs[self.CAMERA_PREVIEW_PORT])
File "/usr/lib/python2.7/dist-packages/picamera/renderers.py", line 512, in init
self.renderer.connect(source)
File "/usr/lib/python2.7/dist-packages/picamera/mmalobj.py", line 1467, in connect
self._connection = MMALConnection(source, self.inputs[0])
File "/usr/lib/python2.7/dist-packages/picamera/mmalobj.py", line 1280, in init
prefix="Failed to enable connection")
File "/usr/lib/python2.7/dist-packages/picamera/exc.py", line 157, in mmal_check
raise PiCameraMMALError(status, prefix)
picamera.exc.PiCameraMMALError: Failed to enable connection: Out of resources (other than memory)

Glad you finally got access to your server!

Genral Notes

In the process of developing my setup I made a couple of decisions:

  • I stick to python 3.x as I have no legacy code to maintain.
  • I set up the server based on Raspbian Jessie Lite with minimal GPU memory to have memory available for the server.

You seem to have set up on a normal Raspbian image and I cannot comment on resources.

Running the Notebook Server as User pi

  • I just executed configure_jupyter.sh as user pi after adjusting the notebook directory in the script to \home\pi\notebooks. As an alternative you can also run the script as is and then edit the configuration file by hand. (/home/pi/.jupyter/...)
  • I am able to start the server as user pi by just running jupyter notebook.

Using picamera

Note that picamera might be installed for the Python versions that come with Raspian. I have no camera module to test with but am pretty sure that you need to install pycamera for the Python version that you use in the notebook.

If you stick wth Python 3.6.0 for the notebook and pip --version reports the same version Python version, you should be able to just run sudo pip install picamera.

Eckhard

Note that the python shell generated a lot of segmentation faults and Bus errors because libreadline-dev.

For a functional python 3.6 shell you need to re-install python 3.6.0. Just clone the latest version of install_python.sh and run it after deleting the following two lines.

pip3 install pip --upgrade
ln -s /usr/local/bin/pip3 /usr/local/bin/pip

Trust that we can call the original issue fixed.