{"id":6323,"library":"bpython","title":"bpython","description":"bpython is a lightweight Python interpreter that provides a fancy curses-based interface to the standard Python REPL. It enhances the interactive experience with features such as syntax highlighting, expected parameter lists, auto-indentation, and autocompletion. It also includes unique functionalities like 'rewind' (undoing the last line), code pastebin, and in-editor session editing. The library is actively maintained, with version 0.26 being the latest release, and new versions often focus on supporting the latest Python releases.","status":"active","version":"0.26","language":"en","source_language":"en","source_url":"https://github.com/bpython/bpython","tags":["terminal","repl","interactive","console","debugging"],"install":[{"cmd":"pip install bpython","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"Required for syntax highlighting.","package":"Pygments","optional":false},{"reason":"Required for the terminal interface, version >=0.4.0.","package":"curtsies","optional":false},{"reason":"Required for core functionality.","package":"greenlet","optional":false},{"reason":"Required for locating configuration files.","package":"pyxdg","optional":false},{"reason":"Required for pastebin functionality.","package":"requests","optional":false},{"reason":"Required for character width calculations in the terminal.","package":"cwcwidth","optional":false},{"reason":"Required for type hinting compatibility.","package":"typing_extensions","optional":false},{"reason":"Optional, for experimental multiline completion, version >=0.16.","package":"jedi","optional":true},{"reason":"Optional, enables clipboard copy/paste functionality.","package":"pyperclip","optional":true},{"reason":"Optional, previously used for the bpython-urwid backend, which is now deprecated (<3.0).","package":"urwid","optional":true}],"imports":[{"note":"The primary way to use bpython is by running it directly from your terminal.","symbol":"bpython (command line)","correct":"$ bpython"},{"note":"The 'embed' function is typically imported directly from the bpython package for programmatic use. Direct import of bpython.embed as a module might work but is not the idiomatic way to access the function.","wrong":"import bpython.embed # direct import without 'from'","symbol":"embed","correct":"from bpython import embed"}],"quickstart":{"code":"import bpython\n\ndef my_function(x, y):\n    return x * y\n\nprint(\"Starting bpython embedded session...\")\n# You can pass a dictionary of local variables to the embed function\nbpython.embed(locals={'my_func': my_function, 'value': 10})\nprint(\"Exited bpython embedded session.\")","lang":"python","description":"While bpython is most commonly started by typing `bpython` in the terminal, you can also embed it programmatically within your Python scripts. This allows you to drop into an interactive bpython session at a specific point in your code, with access to local variables, useful for debugging or interactive exploration."},"warnings":[{"fix":"Upgrade Python to 3.10+ or downgrade bpython to 0.25 or earlier for Python 3.9 compatibility.","message":"bpython version 0.26 and newer dropped support for Python 3.9. If you are on Python 3.9, you must use an older version of bpython (e.g., 0.25) or upgrade your Python interpreter. This contradicts the general PyPI 'requires_python: >=3.9' but is explicit in release notes.","severity":"breaking","affected_versions":"0.26+"},{"fix":"Migrate to the default `curses` backend or the deprecated `urwid` backend if necessary.","message":"The `bpython-cli` rendering backend was entirely removed in version 0.25, following its deprecation in 0.19. If you were explicitly using this backend, your setup will break.","severity":"breaking","affected_versions":"0.25+"},{"fix":"Upgrade to Python 3 (preferably 3.10+ for current bpython versions).","message":"Support for Python 2 was completely dropped in version 0.21. Attempts to run bpython 0.21 or newer with Python 2 will fail.","severity":"breaking","affected_versions":"0.21+"},{"fix":"Upgrade Python to 3.10+ or downgrade bpython to 0.24 or earlier for Python 3.7/3.8 compatibility.","message":"Support for Python 3.7 and 3.8 was dropped in version 0.25. Users on these Python versions must use an older bpython release (e.g., 0.24) or upgrade their Python interpreter.","severity":"breaking","affected_versions":"0.25+"},{"fix":"Run `pip install pyperclip` in your environment.","message":"For clipboard functionality (copy/paste from/to bpython), the `pyperclip` package must be installed separately. Without it, clipboard operations will not work.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Upgrade to bpython 0.22 or newer to ensure `embed()` correctly respects the `locals` argument. (Fixed in #841 and released in 0.22).","message":"Prior to version 0.22, the `bpython.embed()` function did not correctly honor local variables passed to it when embedded within a script. This meant the embedded session might not have access to the expected local scope.","severity":"gotcha","affected_versions":"<0.22"}],"env_vars":null,"last_verified":"2026-04-15T00:00:00.000Z","next_check":"2026-07-14T00:00:00.000Z"}