det-lab / jupyterhub-deploy-kubernetes-jetstream

CDMS JupyterHub deployment on XSEDE Jetstream
0 stars 1 forks source link

making a kernel in JupyterLab #81

Closed pibion closed 2 years ago

pibion commented 2 years ago

I'm trying to turn a python environment into a jupyter kernel (see https://github.com/det-lab/jupyterhub-deploy-kubernetes-jetstream/issues/80).

Following and sometimes modifying suggestions at https://janakiev.com/blog/jupyter-virtual-envs/, I tried the following commands:

python3 -m venv AMY
source AMY/bin/activate
# Then I wanted to see if I could install something
python3 -m pip install requests
pip install ipykernel
python -m ipykernel --user install --name=AMY

The install commands seemed to work - I could see ipykernel and requests stuff in AMY/lib/python3.8/site-packages/. The output from the above commands was

(AMY) bash-4.2$ python -m ipykernel --user install --name=AMY
[IPKernelApp] WARNING | Unrecognized alias: 'name', it will have no effect.
NOTE: When using the `ipython kernel` entry point, Ctrl-C will not work.

To exit, you will have to explicitly quit this process, by either sending
"quit" from a client, or using Ctrl-\ in UNIX-like environments.

To read more about this, see https://github.com/ipython/ipython/issues/2049

To connect another client to this kernel, use:
    --existing kernel-395.json

But when I opened a new notebook, there was no additional kernel option.

@zonca do you know how to create a kernel from a python environment?

zonca commented 2 years ago

Maybe --user needs to be after install?

Please double check in the official docs: https://ipython.readthedocs.io/en/stable/install/kernel_install.html

zonca commented 2 years ago

Create env

python3 -m venv AMY
source AMY/bin/activate
# Then I wanted to see if I could install something
python3 -m pip install requests
pip install ipykernel

Install kernel

python -m ipykernel install --user --name=AMY

Force reload JupyterLab in the browser

image

It works fine, it was just the wrong position of --user, for example:

python -m ipykernel --user install

launches ipykernel instead of installing it