prompt-toolkit / ptpython

A better Python REPL
BSD 3-Clause "New" or "Revised" License
5.1k stars 280 forks source link

ptpython fails to import within jupyter-console #579

Open eo1989 opened 1 month ago

eo1989 commented 1 month ago

I attempted to run ptpython from within jupyter-console (jc from now on; for the signature help, docs, vim keybindings & overall better ergonomics). First after installing into the jupyterlab venv (via pipx inject), running jc didnt import the package (my guess is it's running a separate python interp that isnt connected to the top level "jupyterlab" venv), anyway, "%pip install ptpython" allowed for the package to be installed into the local jc repl. The error I'm bringing up is that when I followed the instructions:

from ptpython.repl import embed

jc returned the following error:

In [5]: import ptpython.repl.embed
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
Cell In[5], line 1
----> 1 import ptpython.repl.embed

File ~/.pyenv/versions/gen/lib/python3.12/site-packages/ptpython/__init__.py:3
      1 from __future__ import annotations
----> 3 from .repl import embed
      5 __all__ = ["embed"]

File ~/.pyenv/versions/gen/lib/python3.12/site-packages/ptpython/repl.py:23
     20 from dis import COMPILER_FLAG_NAMES
     21 from typing import Any, Callable, ContextManager, Iterable
---> 23 from prompt_toolkit.formatted_text import OneStyleAndTextTuple
     24 from prompt_toolkit.patch_stdout import patch_stdout as patch_stdout_context
     25 from prompt_toolkit.shortcuts import (
     26     clear_title,
     27     set_title,
     28 )

ImportError: cannot import name 'OneStyleAndTextTuple' from 'prompt_toolkit.formatted_text' (/home/rocket/.pyenv/versions/gen/lib/python3.12/site-packages/prompt_toolkit/formatted_text/__init__.py)

I noticed in some other threads you say something along the lines that "even python 3.12 and 3.13 should work fine," or words to that effect.

Running Ubuntu 22.04.4 LTS Jammy (WSL2g) python 3.12.2 ptpython 3.0.26 prompt-toolkit 3.0.36

Justaus3r commented 1 month ago

Same error here. Instead i am running the ptpython repl On Windows 11 . ptpython version: ptpython-3.0.26. errors out on both python 3.11 and 3.12 for me

patrickrfisher commented 1 week ago

Evelyn I will help