Open dcguim opened 1 day ago
I found a workaround through pyvenv
, using the following function-hook, in my use-package :config
section:
:config
;; Automatically activate the Poetry virtual environment when starting ein:run
(defun ein-activate-poetry-venv ()
"Activate the Poetry virtual environment before running ein:run."
(let ((venv-path (string-trim (shell-command-to-string "poetryenv"))))
(when (and venv-path (file-exists-p (concat venv-path "/bin/activate")))
(pyvenv-activate (concat venv-path "/bin/activate")))))
;; Hook to activate the Poetry environment before running ein
(add-hook 'ein:notebooklist-login-hook 'ein-activate-poetry-venv)
I also created the following function in my .zshrc
:
function poetryenv() {
if [[ -f "pyproject.toml" ]]; then
echo $(poetry env info --path)
else
echo "No pyproject.toml - current directory doesn't seem to contain a poetry project."
return 1
fi
}
This workaround is enough although I feel it could be better for poetry users if it was integrated directly into ein
.
I would expect ein to be able pick up my poetry jupyter kernel:
Of course I would be able to run, in the terminal from my "llama-app-backend-BtvjZBul-py3.11" virtualenv
Unfortunately when selecting
python3
ipykernel from ein's notebooklist menu, and executing the import statement again:system info
My poetry env:
I have the following dependencies in my pyproject.toml: