pathbird / poetry-kernel

Python Jupyter kernel using Poetry for reproducible notebooks
MIT License
246 stars 7 forks source link

poetry-kernel uses Jupyter env instead of notebook env #7

Open drakesiardxy opened 1 year ago

drakesiardxy commented 1 year ago

If a poetry pyproject.toml is used to create the environment for the Jupyter lab (adding poetry-kernel as a dependency), then no matter in which working directory the jupyter server is started, any notebook that is opened with the "poetry" kernel will have the Jupyter environment, not the environment of the notebook's project.

Minimal example: https://github.com/drakesiardxy/poetry-kernel-bug To replicate: Create the jupyer-base env and the kernel_a env separately, then start the jupyter server with the first environment and attempt to run kernel_a.ipynb using the "Poetry" kernel. pandas will be missing, because the notebook will have been launched with the environment of the server, not the environment belonging to the notebook's project.

bluss commented 1 year ago

Would be very powerful if poetry had a flag or some way to avoid this. My fork that uses rye for a kernel in the same way, it handles the environment "nesting" fine.

Edit: Poetry doesn't need a flag - but maybe that you create the environment for the nested project explicitly. After that, nested poetry run works fine.