eWaterCycle / infra

Instructions for system administrators to deploy the eWaterCycle platform
Apache License 2.0
0 stars 0 forks source link

Installation jupyter kernel needs permission #112

Closed SarahAlidoost closed 3 years ago

SarahAlidoost commented 3 years ago

To add a new kernel using the Python in the user conda environment e.g. testewatercycle to the python which runs the Jupyter, we can run: ~/.conda/envs/testewatercycle/bin/python -m ipykernel install --prefix=/opt/conda/envs/ewatercycle --name 'testewatercycle' . see more details.

This returns [Errno 13] Permission denied: '/opt/conda/envs/ewatercycle/share/jupyter/kernels/testewatercycle'. It seems that the new kernel i.e. testewatercycle should be added to a json file that is located here: /opt/conda/envs/ewatercycle/share/jupyter/kernels/python3/kernel.json.

sverhoeven commented 3 years ago

Refs #110

Tested my self with

conda create -n mytestenv -c conda-forge python=3.8 ipykernel
/home/sverhoeven/.conda/envs/mytestenv/bin/python -m ipykernel install --prefix=/home/sverhoeven/.local/ --name 'mytestenv'
jupyter kernelspec list
# Reload Jupyter Lab page in browser

The new kernel showed up and notebook ran with Python 3.8 instead of default 3.9.

Jupyter looks for kernel specs in data paths of jupyter --paths which includes ~/.local/share/jupyter so I used ~/.local as prefix during kernel install which works.

sverhoeven commented 3 years ago

Instead of using --prefix use --user to install kernel in home dir. This is the way according to the docs. So

/home/sverhoeven/.conda/envs/mytestenv/bin/python -m ipykernel install --user --name 'mytestenv'
# Installed kernelspec mytestenv in /home/sverhoeven/.local/share/jupyter/kernels/mytestenv
SarahAlidoost commented 3 years ago

Instead of using --prefix use --user to install kernel in home dir. This is the way according to the docs. So

/home/sverhoeven/.conda/envs/mytestenv/bin/python -m ipykernel install --user --name 'mytestenv'
# Installed kernelspec mytestenv in /home/sverhoeven/.local/share/jupyter/kernels/mytestenv

Thanks, this works. I commit it to #110.