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

Is it possible to make poetry-kernel work with JupyterHub? #6

Open
MsLimon opened this issue Apr 26, 2022 · 2 comments
Open

Is it possible to make poetry-kernel work with JupyterHub? #6

MsLimon opened this issue Apr 26, 2022 · 2 comments

Comments

@MsLimon
Copy link

MsLimon commented Apr 26, 2022

Hi!

We have a multi-user JupyterHub instance and we would like to use your library. So far we have only been able to see the poetry-kernel button in the kernel selection screen by installing poetry kernel at the user level (if we install poetry kernel from the user that launches JupyterHub, the root user, the button does not show). But the problem that we have is that when we press the poetry button and create a new notebook in a folder with a poetry project (and ipykernel installed), the kernel is never connected so no code can be executed. The generated logs are the following:

Apr 26 15:30:26 labs-ubuntu-20-04 python3[446728]: [I 2022-04-26 15:30:26.298 SingleUserLabApp restarter:66] AsyncIOLoopKernelRestarter: restarting kernel (2/5), new random ports
Apr 26 15:30:26 labs-ubuntu-20-04 python3[1028846]: Traceback (most recent call last):
Apr 26 15:30:26 labs-ubuntu-20-04 python3[1028846]:   File "/usr/lib/python3.8/runpy.py", line 194, in _run_module_as_main
Apr 26 15:30:26 labs-ubuntu-20-04 python3[1028846]:     return _run_code(code, main_globals, None,
Apr 26 15:30:26 labs-ubuntu-20-04 python3[1028846]:   File "/usr/lib/python3.8/runpy.py", line 87, in _run_code
Apr 26 15:30:26 labs-ubuntu-20-04 python3[1028846]:     exec(code, run_globals)
Apr 26 15:30:26 labs-ubuntu-20-04 python3[1028846]:   File "/home/marta/.local/lib/python3.8/site-packages/poetry_kernel/__main__.py", line 68, in <module>
Apr 26 15:30:26 labs-ubuntu-20-04 python3[1028846]:     main()
Apr 26 15:30:26 labs-ubuntu-20-04 python3[1028846]:   File "/home/marta/.local/lib/python3.8/site-packages/poetry_kernel/__main__.py", line 37, in main
Apr 26 15:30:26 labs-ubuntu-20-04 python3[1028846]:     proc = subprocess.Popen(cmd)
Apr 26 15:30:26 labs-ubuntu-20-04 python3[1028846]:   File "/usr/lib/python3.8/subprocess.py", line 858, in __init__
Apr 26 15:30:26 labs-ubuntu-20-04 python3[1028846]:     self._execute_child(args, executable, preexec_fn, close_fds,
Apr 26 15:30:26 labs-ubuntu-20-04 python3[1028846]:   File "/usr/lib/python3.8/subprocess.py", line 1704, in _execute_child
Apr 26 15:30:26 labs-ubuntu-20-04 python3[1028846]:     raise child_exception_type(errno_num, err_msg, err_filename)
Apr 26 15:30:26 labs-ubuntu-20-04 python3[1028846]: FileNotFoundError: [Errno 2] No such file or directory: 'poetry'

This looks like poetry is not being found by the library although it is indeed installed both at the root and user level. Is there a way to solve this? Or is this case out of the scope of the library for now?

@rmnvncnt
Copy link

rmnvncnt commented Dec 7, 2022

I have the same issue. I can select the Poetry kernel while running a notebook, but the kernel fail to connect. Jupyterhub logs state a 404 error : kernel does not exist.

I found an alternative solution for single user environments : poetry run python -m ipykernel install --user --name myenv then restart the server.

@twavv
Copy link
Contributor

twavv commented Dec 7, 2022

Hmmm I'm not sure that your issue (@rmnvncnt) is the same as the OP. Can you include some of the server side logs?

@MsLimon I know this is a few months past when you posted your original issue, but it looks like poetry is just not on the PATH. This project doesn't actually depend on Poetry (in the Python sense of "this package does not import poetry), it just assumes the poetry executable is available.

To debug you might want to make sure you can run poetry from the command line, then see what which poetry spits out and make sure it's on the PATH for the Jupyter notebook server. How the PATH is set is very dependent on how you've set things up so I can't really provide any more guidance than that.

One option could be to make this project directly depend on Poetry, but I'm a little bit resistant to that since it might use a different version of Poetry than the actual project would use (e.g., the version that poetry-kernel refers to is older than what you have installed globally).

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

3 participants