Loading video player…

Get Started With bpython

00:00 Get Started With bpython.

00:03 Unlike standalone Python distributions such as CPython, PyPy, or Anaconda, bpython is merely a pure Python package serving as a lightweight wrapper around a chosen Python interpreter. Therefore, you can use bpython on top of any particular Python distribution version or even a virtual environment, which gives you plenty of flexibility. At the same time, bpython remains a familiar Python REPL with only a few essential features, such as syntax highlighting and auto-completion borrowed from the full-fledged Python IDEs.

00:35 This minimalistic approach contrasts with tools such as IPython, which is yet another alternative to the Python standard REPL popular in the data science community.

00:46 There are a few ways to get bpython onto your computer. Package managers such as Homebrew and APT offer pre-built versions of bpython for your operating system, but they’re likely obsolete and hardwired to the system-wide Python interpreter.

01:01 While you can build the latest bpython version from its source code by hand, it’s better to install it into a virtual environment with pip.

01:32 It’s common to have bpython installed in several copies across multiple virtual environments. This allows you to wrap bpython around the specific Python interpreter that you use to create the virtual environment in the first place. Unfortunately, bpython isn’t natively supported on Windows.

01:50 This is because it depends on the curses library, which is only available on Unix-like systems such as macOS and Linux. The official documentation mentions a work-around which relies on an unofficial binary for Windows, but it doesn’t seem to work anymore. If you are on Windows, then your best bet is to install the Windows Subsystem for Linux, known as WSL, and use bpython from there.

02:45 Once it’s installed, there are two different commands you can use to start bpython. Generally, it’s preferable to choose the more explicit second command, which invokes bpython as a runnable Python module. This way, you’ll ensure that you’re running the bpython program installed into the currently active virtual environment.

03:03 The bare bpython command can silently fall back to the program installed globally if there is one. It could also be aliased to a different executable in your shell taking precedence over the local bpython module.

03:18 The Django web framework can detect bpython if it’s installed in your virtual environment. The framework will automatically run bpython when you execute the shell command to bring up the Python interactive interpreter with your project files on the module search path.

03:41 You’ve now learned how to install and run bpython as an alternative Python REPL, so it’s time to explore its key features. Over the next few sections of the course, you’ll discover several ways that bpython can increase your productivity as a Python programmer regardless of your skill level, and you’ll start out by looking at typo spotting.

Become a Member to join the conversation.