User Tools

Site Tools


other:python:starting

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revision Both sides next revision
other:python:starting [2022/01/04 20:45]
jypeter [Ultra quick-start on the LSCE servers]
other:python:starting [2022/01/04 22:06]
jypeter [Using the LSCE jupyterhub server] Added user kernel definition
Line 123: Line 123:
   - Learn Python by reading what you need on the [[other:​python:​jyp_steps|JYP'​s recommended steps for learning python]] page   - Learn Python by reading what you need on the [[other:​python:​jyp_steps|JYP'​s recommended steps for learning python]] page
  
 +
 +===== Using the LSCE jupyterhub server =====
 +
 +The [[https://​intranet.lsce.ipsl.fr/​informatique/​en/​jupyter/​index.php|LSCE jupyterhub notebook server]] is available for users with a LSCE Linux account: ​
 +  * from a computer on the LSCE wired network: https://​jupyter.lsce.ipsl.fr/​
 +  * from other computers: start the [[https://​intranet.lsce.ipsl.fr/​informatique/​fr/​vpn-forticlient.php#​vpnlsce|LSCE VPN]] before opening https://​jupyter.lsce.ipsl.fr/​
 +
 +==== Using a non-standard kernel ====
 +
 +Note: a //kernel// is a specific python environment/​distribution
 +
 +The LSCE jupyterhub server can be used to open //​Notebooks//​ using pre-configured Python or R //​kernels//​. It is also possible to define additional per-user kernels by adding [[https://​jupyter-client.readthedocs.io/​en/​stable/​kernels.html#​kernel-specs|kernel configuration directories]] in the user's home directory
 +
 +The steps below show how to add a specific [[other:​python:​starting#​cdat|CDAT environment]] kernel, but can be easily adapted for using other kernels
 +
 +  - Initialize your (favorite) Python environment in a terminal, and (as usual) check which Python executable you are using\\ <​code>​ >which python
 +/​usr/​bin/​python
 +
 + >​source ~jypeter/​.conda3_21-02_jyp.csh
 + >​conda activate cdatm_py3
 +
 +(cdatm_py3) ​ >which python
 +/​home/​share/​unix_files/​cdat/​miniconda3_21-02/​envs/​cdatm_py3/​bin/​python</​code>​
 +  - Determine where the kernel configuration files of the **active** python are located\\ <​code>​ >jupyter kernelspec list
 +Available kernels:
 +  python3 ​    /​home/​share/​unix_files/​cdat/​miniconda3_21-02/​envs/​cdatm19_nompi_py3/​share/​jupyter/​kernels/​python3</​code>​
 +  - Copy the existing kernel directory that you have found to your home directory. You can use the existing kernel name, or use a new kernel name (using only ASCII letters, numbers, ​ ''​-''​ hyphen, ''​.''​ period and ''​_''​ underscore)\\ <​code>​ >cp -pr /​home/​share/​unix_files/​cdat/​miniconda3_21-02/​envs/​cdatm19_nompi_py3/​share/​jupyter/​kernels/​python3 ~/​.local/​share/​jupyter/​kernels
 + >​cp -pr /​home/​share/​unix_files/​cdat/​miniconda3_21-02/​envs/​cdatm19_nompi_py3/​share/​jupyter/​kernels/​python3 ~/​.local/​share/​jupyter/​kernels/​my_favorite_kernel
 +
 + >​ls ~/​.local/​share/​jupyter/​kernels/​
 +my_favorite_kernel/ ​   python3/
 +</​code>​
 +  - Check that the ''​kernelspec list''​ command now finds the new kernel(s)\\ <​code>​ >jupyter kernelspec list
 +Available kernels:
 +  my_favorite_kernel ​   your_home_dir/​.local/​share/​jupyter/​kernels/​my_favorite_kernel
 +  python3 ​              ​your_home_dir/​.local/​share/​jupyter/​kernels/​python3</​code>​
 +  - You can optionally change the value of the ''​display_name''​ parameter in the ''​kernel.json''​ configuration file if you want to customize the name that will appear in the jupyterhub kernel menus\\ <​code>​ >ls your_home_dir/​.local/​share/​jupyter/​kernels/​my_favorite_kernel
 +kernel.json ​ logo-32x32.png ​ logo-64x64.png
 +
 + >​cat your_home_dir/​.local/​share/​jupyter/​kernels/​my_favorite_kernel/​kernel.json
 +{
 + "​argv":​ [
 +  "/​home/​share/​unix_files/​cdat/​miniconda3_21-02/​envs/​cdatm19_nompi_py3/​bin/​python",​
 +  "​-m",​
 +  "​ipykernel_launcher",​
 +  "​-f",​
 +  "​{connection_file}"​
 + ],
 + "​display_name":​ "My favorite Python kernel",​
 + "​language":​ "​python"​
 +</​code>​
 +  - refresh the https://​jupyter.lsce.ipsl.fr/​ page and the new kernel(s) should appear in the kernels'​ related menus
 ===== Python distributions available for LSCE users ===== ===== Python distributions available for LSCE users =====
  
other/python/starting.txt · Last modified: 2024/05/30 13:41 by jypeter