Registry / testing / bpython

bpython

JSON →
library0.26pypypi✓ verified 85d ago

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.

pip install bpython
INSTALL
IMPORT
SIG · BPYTHON
B
bpython
testingpythonv0.26
Install
3.7s avg
Import
Disk
41MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.26 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
installs and imports cleanly · install 0.0s · import 0.000s · 46.5MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 3.7s · import 0.000s · 44MB
41MB installed
● package 41MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

bpython (command line)
$ bpython
The primary way to use bpython is by running it directly from your terminal.
embed
from bpython import embed
import bpython.embed # direct import without 'from'
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.

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.

import bpython def my_function(x, y): return x * y print("Starting bpython embedded session...") # You can pass a dictionary of local variables to the embed function bpython.embed(locals={'my_func': my_function, 'value': 10}) print("Exited bpython embedded session.")
bpython --version
Debug
Known issues
breakingbpython 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.
fix
Upgrade Python to 3.10+ or downgrade bpython to 0.25 or earlier for Python 3.9 compatibility.
affects: 0.26+
breakingThe `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.
fix
Migrate to the default `curses` backend or the deprecated `urwid` backend if necessary.
affects: 0.25+
breakingSupport for Python 2 was completely dropped in version 0.21. Attempts to run bpython 0.21 or newer with Python 2 will fail.
fix
Upgrade to Python 3 (preferably 3.10+ for current bpython versions).
affects: 0.21+
breakingSupport 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.
fix
Upgrade Python to 3.10+ or downgrade bpython to 0.24 or earlier for Python 3.7/3.8 compatibility.
affects: 0.25+
gotchaFor clipboard functionality (copy/paste from/to bpython), the `pyperclip` package must be installed separately. Without it, clipboard operations will not work.
fix
Run `pip install pyperclip` in your environment.
affects: All versions
gotchaPrior 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.
fix
Upgrade to bpython 0.22 or newer to ensure `embed()` correctly respects the `locals` argument. (Fixed in #841 and released in 0.22).
affects: <0.22
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'configparser'
This typically occurs on older Python 2.7 installations (especially on macOS) when an outdated 'six' package (pre-1.5) is loaded, preventing the 'configparser' module from being correctly found.
fix
Ensure a sufficiently new version of the 'six' package is available in your Python environment. On macOS with Python 2.7, adding `export PYTHONPATH=/Library/Python/2.7/site-packages/:$PYTHONPATH` to your `~/.bashrc` or `~/.zshrc` can help resolve the `sys.path` issue. Upgrading your Python version is also recommended.
pkg_resources.DistributionNotFound: ndg-httpsclient
This error arises when the 'ndg-httpsclient' dependency, required by 'pyOpenSSL', fails to install correctly. It's often observed with older Python versions (like 2.6.X) and 'pip' versions where dependency resolution was less robust.
fix
Manually install the missing dependencies: `pip install pyOpenSSL pyasn1 ndg-httpsclient`. Upgrading your Python installation to 2.7.7 or newer is also recommended to avoid this issue.
Upload failed: hostname 'bpaste.net' doesn't match either of '*.qabana.nl', 'qabana.nl'
This pastebin upload error is commonly caused by a lack of SNI (Server Name Indication) support in the Python 'requests' library, which can occur with older Python versions. The default pastebin service (bpaste.net) might also have updated its SSL certificates or moved, leading to hostname mismatches.
fix
Upgrade your Python installation to version 2.7.7 or newer, and ensure 'pyOpenSSL', 'pyasn1', and 'ndg-httpsclient' are installed to provide necessary SSL/TLS capabilities.
ModuleNotFoundError: No module named 'readline'
The 'readline' module provides advanced line editing and history features, but it is primarily a Unix-specific module and is not available by default on Windows. This leads to missing functionality or errors when bpython attempts to use it on Windows.
fix
On Windows, bpython's full functionality may be limited. While 'pyreadline3' can provide 'readline'-like features for general Python, bpython on Windows often requires specific workarounds. Install `windows-curses` (`pip install windows-curses`) and run `bpython-curses` instead of `bpython` from your terminal.
AttributeError: 'FakeOutput' object has no attribute 'encoding'
This specific 'AttributeError' occurs when bpython's internal `FakeOutput` object, which replaces `sys.stdout` for its interactive features, is accessed for an 'encoding' attribute that it doesn't possess, unlike a standard `sys.stdout` object.
fix
This was an internal bug in older bpython versions. The primary fix is to ensure you are using the latest version of bpython (0.26) as such issues are typically resolved in newer releases.
Upgrade
Version history
0.26latest on PyPI · released Oct 28, 2025
Audit
Dependencies
PygmentsrequiredRequired for syntax highlighting.
curtsiesrequiredRequired for the terminal interface, version >=0.4.0.
greenletrequiredRequired for core functionality.
pyxdgrequiredRequired for locating configuration files.
requestsrequiredRequired for pastebin functionality.
cwcwidthrequiredRequired for character width calculations in the terminal.
typing_extensionsrequiredRequired for type hinting compatibility.
jedioptionalOptional, for experimental multiline completion, version >=0.16.
pyperclipoptionalOptional, enables clipboard copy/paste functionality.
urwidoptionalOptional, previously used for the bpython-urwid backend, which is now deprecated (<3.0).
Agent activity
14 hits · last 30 days
node
12
OpenAI (training)
1
Resources