Skip to content

Configuring a poetry environment in ein #898

@dcguim

Description

@dcguim

I would expect ein to be able pick up my poetry jupyter kernel:

 > poetry run jupyter kernelspec list
Available kernels:
  python3          /Users/dguim/Library/Caches/pypoetry/virtualenvs/llama-app-backend-BtvjZBul-py3.11/share/jupyter/kernels/python3

Of course I would be able to run, in the terminal from my "llama-app-backend-BtvjZBul-py3.11" virtualenv

>>> import langchain_openai
>>> 

Unfortunately when selecting python3 ipykernel from ein's notebooklist menu, and executing the import statement again:

In [2]:
import langchain_openai

Truncated Traceback (Use C-c C-$ to view full TB):
Cell In[2], line 1
----> 1 import langchain_openai

ModuleNotFoundError: No module named 'langchain_openai'

system info

;; Use EIN for Jupyter notebook integration
(use-package ein
  :ensure t
  :init
  ;; Set default notebook directory to current directory
  (setq ein:jupyter-server-use-command "/Users/dguim/Library/Caches/pypoetry/virtualenvs/llama-app-backend-BtvjZBul-py3.11/bin/jupyter")
;;  (custom-set-variables '(ein:jupyter-server-use-subcommand "run jupyter notebook"))
  (setq ein:jupyter-server-use-containers nil)
  (setq ein:jupyter-default-notebook-directory default-directory)
  :config
  ;; Enable auto-completion and undo in notebooks
  (setq ein:use-auto-complete t)
  (setq ein:worksheet-enable-undo t)
  ;; Keybindings for opening notebooks and connecting to a running Jupyter server
  :bind (("C-c C-j l" . ein:notebooklist-login)))

My poetry env:

> poetry env info

Virtualenv
Python:         3.11.10
Implementation: CPython
Path:           /Users/dguim/Library/Caches/pypoetry/virtualenvs/llama-app-backend-BtvjZBul-py3.11
Executable:     /Users/dguim/Library/Caches/pypoetry/virtualenvs/llama-app-backend-BtvjZBul-py3.11/bin/python
Valid:          True

Base
Platform:   darwin
OS:         posix
Python:     3.11.10
Path:       /opt/homebrew/opt/[email protected]/Frameworks/Python.framework/Versions/3.11
Executable: /opt/homebrew/opt/[email protected]/Frameworks/Python.framework/Versions/3.11/bin/python3.11

I have the following dependencies in my pyproject.toml:

[tool.poetry.dependencies]
langchain-openai = "^0.1.1"
openai = "^1.16.2"
langchain-community = "^0.0.31"
langchain = "^0.1.14"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions