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

conf_jupyter.sh fails #22

Closed
Kevin--R opened this issue May 18, 2018 · 15 comments
Closed

conf_jupyter.sh fails #22

Kevin--R opened this issue May 18, 2018 · 15 comments

Comments

@Kevin--R
Copy link

Looks like issue #16 may have returned:

pi@Jupyter-Pi2:~/jns $ ./conf_jupyter.sh
Writing default config to: /home/pi/.jupyter/jupyter_notebook_config.py
Installing IPython kernel spec
Enabling: jupyterlab
- Writing config: /home/pi/.jupyter
    - Validating...
      jupyterlab 0.32.1 OK
Enabling notebook extension jupyter-js-widgets/extension...
      - Validating: OK
Enabling notebook extension bqplot/extension...
      - Validating: OK
Enabling IPython clusters tab
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100 38002  100 38002    0     0  74637      0 --:--:-- --:--:-- --:--:-- 74637
-- Cloning https://github.com/tj/n to '/home/pi/n/n/.repo'...
-- Running local n installation to '/home/pi/n/bin'...
-- Shell initialization file '/home/pi/.bashrc' updated.
-- Installing helper scripts in '/home/pi/n/bin'...
-- Installing the requested Node.js version(s)...
   1 of 1: stable...
 
     install : node-v10.0.0
       mkdir : /home/pi/n/n/versions/node/10.0.0
       fetch : https://nodejs.org/dist/v10.0.0/node-v10.0.0-linux-armv7l.tar.gz
######################################################################## 100.0%
   installed : v10.0.0
 
=== n successfully installed.
  The active Node.js version is: v10.0.0
 
  Run `n -h` for help.
  To update n later, run `n-update`.
  To uninstall, run `n-uninstall`.
 
  IMPORTANT: OPEN A NEW TERMINAL TAB/WINDOW or run `. /home/pi/.bashrc`
             before using n and Node.js.
===
 
Errored, use --debug for full output:
ValueError: Please install nodejs 5+ and npm before continuing. nodejs may be installed using conda or directly from the nodejs website.
 
Errored, use --debug for full output:
ValueError: Please install nodejs 5+ and npm before continuing. nodejs may be installed using conda or directly from the nodejs website.
 
Errored, use --debug for full output:
ValueError: Please install nodejs 5+ and npm before continuing. nodejs may be installed using conda or directly from the nodejs website.
@kleinee
Copy link
Owner

kleinee commented May 19, 2018

Hi @Kevin--R Kevin--R,

Unfortunately you are right - I was able to reproduce your findings but I have no new workaround as of yet. I only can get conf_jupyter.sh to work manually like so:

  • check if node is installed node --version
  • if it is: re-run conf_jupyter.sh
  • if it isn't: run inst_node.sh followed by source /home/pi/.bashrc and then run conf_jupyter.sh

Hope this helps for the moment - I'll try to find a way to automate it (again). If this works for you or if you or anybody else finds a fix, please do let men know. - Thanks

kleinee added a commit that referenced this issue May 19, 2018
@kleinee
Copy link
Owner

kleinee commented May 19, 2018

Hi @Kevin--R,

  • I finally foundnd a way to fix this issue in conf_jupyter.sh
  • keep it open for the moment just in case you want to comment

kleinee added a commit that referenced this issue May 19, 2018
@kleinee
Copy link
Owner

kleinee commented May 19, 2018

@Kevin--R: you were faster to identify jupyter-widgets/ipywidgets#2061 -- I just downgraded nodejs using n lts. Installation still running...

@Kevin--R
Copy link
Author

Kevin--R commented May 19, 2018

Hi @kleinee

First off I wanted to thank you for the time and effort you put into creating this great resource. I have one jupyter lab server set up and running and I'm currently trying to set another one up for a friend.

I've tried a clean install starting with a freshly imaged SD card and ./conf_jupyter.sh still fails.

pi@Jupyter-Pi2:~/jns $ ./conf_jupyter.sh
Writing default config to: /home/pi/.jupyter/jupyter_notebook_config.py
Installing IPython kernel spec
Enabling: jupyterlab
- Writing config: /home/pi/.jupyter
    - Validating...
      jupyterlab 0.32.1 OK
Enabling notebook extension jupyter-js-widgets/extension...
      - Validating: OK
Enabling notebook extension bqplot/extension...
      - Validating: OK
Enabling IPython clusters tab
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100 38002  100 38002    0     0  72887      0 --:--:-- --:--:-- --:--:-- 72887
-- Cloning https://github.com/tj/n to '/home/pi/n/n/.repo'...
-- Running local n installation to '/home/pi/n/bin'...
-- Shell initialization file '/home/pi/.bashrc' updated.
-- Installing helper scripts in '/home/pi/n/bin'...
-- Installing the requested Node.js version(s)...
   1 of 1: stable...
 
     install : node-v10.0.0
       mkdir : /home/pi/n/n/versions/node/10.0.0
       fetch : https://nodejs.org/dist/v10.0.0/node-v10.0.0-linux-armv7l.tar.gz
######################################################################## 100.0%
   installed : v10.0.0
 
=== n successfully installed.
  The active Node.js version is: v10.0.0
 
  Run `n -h` for help.
  To update n later, run `n-update`.
  To uninstall, run `n-uninstall`.
 
  IMPORTANT: OPEN A NEW TERMINAL TAB/WINDOW or run `. /home/pi/.bashrc`
             before using n and Node.js.
===
 
Errored, use --debug for full output:
ValueError: Please install nodejs 5+ and npm before continuing. nodejs may be installed using conda or directly from the nodejs website.
 
Errored, use --debug for full output:
ValueError: Please install nodejs 5+ and npm before continuing. nodejs may be installed using conda or directly from the nodejs website.
 
Errored, use --debug for full output:
ValueError: Please install nodejs 5+ and npm before continuing. nodejs may be installed using conda or directly from the nodejs website.

I used the manual workaround you described above with the following results:

pi@Jupyter-Pi2:~/jns $ source /home/pi/.bashrc
pi@Jupyter-Pi2:~/jns $ ./conf_jupyter.sh
Writing default config to: /home/pi/.jupyter/jupyter_notebook_config.py
Installing IPython kernel spec
Enabling: jupyterlab
- Writing config: /home/pi/.jupyter
    - Validating...
      jupyterlab 0.32.1 OK
Enabling notebook extension jupyter-js-widgets/extension...
      - Validating: OK
Enabling notebook extension bqplot/extension...
      - Validating: OK
Enabling IPython clusters tab
node is installed, skipping...
> /home/pi/n/bin/npm pack @jupyter-widgets/jupyterlab-manager
jupyter-widgets-jupyterlab-manager-0.35.0.tgz
> node /home/pi/.venv/jns/lib/python3.5/site-packages/jupyterlab/staging/yarn.js install
yarn install v1.5.1
(node:11096) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
info No lockfile found.
[1/4] Resolving packages...
⠂ @jupyter-widgets/jupyterlab-manager@file:../extensions/jupyter-widgets-jupyterlab-manager-0.35.0.tgz 

It runs to this point then it gets stuck in a loop. I got to this point several days ago and let it run overnight and it was still at this point the next morning. It seems there is some issue caused by node updating to version 10 causing failures with jupyter-widgets-jupyterlab-manager installing.

I can usually puzzle my way through issues with linux or python as I have some experience with them (but I'm far from being an expert).

I've tried to follow the issue with jupyterlab-manager here on GitHub but I'm kind of at a loss as I know absolutely nothing about node / yarn.

@Kevin--R
Copy link
Author

@kleinee

wow you're quick

I ran n lts re-ran ./conf_jupyter.sh and it has already progressed past the point where it hung before.

@kleinee
Copy link
Owner

kleinee commented May 19, 2018

@Kevin--R please see my comment above. I did not notice this before you reported the tragic return of issue 16 because I had no reason to upgrade nodejs. When you opened the issue I ran a fresh install. Happy to report that with n lts followed by conf_jupyter.sh installation runs through to the end.

@Kevin--R
Copy link
Author

@kleinee

looks like we're posting at the same time

thanks again for creating this great resource

@kleinee
Copy link
Owner

kleinee commented May 19, 2018

@Kevin--R Glad you like it. And by the way: I am no nodejs expert either...

@Kevin--R
Copy link
Author

Kevin--R commented May 20, 2018

@kleinee

Yesterday evening I did a complete fresh install on a newly imaged SD card and ./conf_jupyter.sh still fails.

After a few attempts, I noticed that if I just call ./conf_jupyter.sh it fails, but if I call bash --norc --noprofile -i ./conf_jupyter.sh it completes without errors.

I found this info. on the page for n-install here: https://github.com/mklement0/n-install

Using this method, I just finished a complete fresh install without errors and without making any changes to your scripts.

@kleinee
Copy link
Owner

kleinee commented May 20, 2018

@Kevin--R

  • first of all: congratulations - hope you can put the server to good use!!!

  • Did you mean inst_node.sh ?

  • Which node version did you install ?

  • After our discussion yesterday I made modifications to inst_node.sh and conf_jupyter.sh.

  • inst_node.sh is supposed to install the lts and latest versions but activating ```its`` for the moment

  • conf_jypyter.sh executes inst_node.sh by invoking it with

bash -i inst_node.sh

@Kevin--R
Copy link
Author

@kleinee
my mistake - I should have wrote ./conf_jupyter.sh in my last post (I corrected the post to avoid confusing others)

I'm getting kind of cross eyed after sitting in front of the computer all morning - sorry for the confusion

@kleinee kleinee closed this as completed May 20, 2018
@Kevin--R
Copy link
Author

@kleinee

in answer to your question, node v8.11.2 (lts) and v10.1.0 (latest) were installed by your scripts and v8.11.2 was made active

@Kevin--R
Copy link
Author

Kevin--R commented May 20, 2018

@kleinee
apparently these lines at the top of .bashrc were causing the problem:

# If not running interactively, don't do anything
case $- in
    *i*) ;;
      *) return;;
esac

it appears that if the calling script (./conf_jupyter.sh in this case) isn't running in interactive mode, calling . /home/pi/.bashrc will nave no effect

@kleinee
Copy link
Owner

kleinee commented May 20, 2018

You are right - thanks for the feedback! Since we now call inst_node.sh with bash -i inst_node,sh, . /home/pi/.bashrc only takes effect if it is placed at the end of inst_node.sh

@kleinee kleinee reopened this May 20, 2018
kleinee added a commit that referenced this issue May 20, 2018
@Kevin--R
Copy link
Author

@kleinee
I tried to do a complete install again today and ./conf_jupyter.sh still fails.

When you call bash -i ./inst_node.sh from ./conf_jupyter.sh it installs node and calls . /home/pi/.bashrc from a child process. When this child process exits, the changes to the environment made by calling . /home/pi/.bashrc are lost and these lines:

jupyter labextension install @jupyter-widgets/jupyterlab-manager
jupyter labextension install bqplot
jupyter labextension install jupyterlab_bokeh  

fail beccause the path to the node executable is not in the environment path.

If you change conf_jupyter.sh to:

#!/bin/bash
# script name:     conf_jupyter.sh
# last modified:   2018/05/21
# sudo:            no

script_name=$(basename -- "$0")
env="/home/pi/.venv/jns"

if [ $(id -u) = 0 ]
then
   echo "usage: ./$script_name"
   exit 1
fi

# activate virtual environment
source $env/bin/activate

# generate config and create notebook directory
# if notebook directory exists, we keep it (-p)
# if configuration file exeists, we overwrite it (-y)

jupyter notebook -y --generate-config
cd $home
mkdir -p notebooks

target=~/.jupyter/jupyter_notebook_config.py

# set up dictionary of changes for jupyter_config.py
declare -A arr
app='c.NotebookApp'
arr+=(["$app.open_browser"]="$app.open_browser = False")
arr+=(["$app.ip"]="$app.ip ='*'")
arr+=(["$app.port"]="$app.port = 8888")
arr+=(["$app.enable_mathjax"]="$app.enable_mathjax = True")
arr+=(["$app.notebook_dir"]="$app.notebook_dir = '/home/pi/notebooks'")
arr+=(["$app.password"]="$app.password = 'sha1:5815fb7ca805:f09ed218dfcc908acb3e29c3b697079fea37486a'")

# apply changes to jupyter_notebook_config.py

for key in ${!arr[@]};do
    if grep -qF $key ${target}; then
        # key found -> replace line
        sed -i "/${key}/c ${arr[${key}]}" $target
    else
        # key not found -> append line
        echo "${arr[${key}]}" >> $target
    fi
done

# install bash kernel
python3 -m bash_kernel.install

# install extensions
jupyter serverextension enable --py jupyterlab
jupyter nbextension enable --py widgetsnbextension --sys-prefix
jupyter nbextension enable --py --sys-prefix bqplot

# activate clusters tab in notebook interface
/home/pi/.venv/jns/bin/ipcluster nbextension enable --user

# install nodejs and node version manager n
# if node is not yet installed
if which node > /dev/null
    then
        echo "node is installed, skipping..."
    else
        # install nodejs and node version manager n
        cd ~/jns
        # fix for issue #22
        curl -L https://git.io/n-install | bash -s -- -y lts latest
        . /home/pi/.bashrc
fi

jupyter lab clean
jupyter labextension install @jupyter-widgets/jupyterlab-manager
jupyter labextension install bqplot
jupyter labextension install jupyterlab_bokeh

Then if you call bash -i conf_jupyter.sh to run the script in interactive mode the script finishes without errors (you'll need to editinst_jns.sh to call it this way also).

This will also eliminate the need for the script inst_node.sh

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

2 participants