Skip to content

ptpython fails to import within jupyter-console #579

Open

Description

@eo1989

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

Activity

  1. Justaus3r commented on May 24, 2024

    @Justaus3r

    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

  2. patrickrfisher commented on Jun 17, 2024

    @patrickrfisher

    Evelyn I will help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions