Flask-Shell-IPython (current version 0.5.3, released September 2024) is a Python package that seamlessly replaces the default `flask shell` command with an enhanced IPython shell. This integration provides developers with advanced interactive features such as syntax highlighting, tab-completion, command history, and IPython's "magic commands," significantly improving the Flask development and debugging experience. The project maintains an active development status with periodic updates.
Install & Compatibility
Where this runs
tested against v0.5.3 · 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
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
The primary feature of `flask-shell-ipython` is that it automatically hooks into the `flask shell` command upon installation. No explicit import or initialization code is required in your Flask application for basic usage. Configuration is done via `app.config['IPYTHON_CONFIG']` if custom IPython settings are desired.
No explicit import needed; installation automatically replaces `flask shell`.
This quickstart demonstrates a minimal Flask application that automatically uses the IPython shell when `flask shell` is executed. It also shows how to configure IPython settings and how to add custom objects (like `app` and `greeting`) to the shell's context using Flask's `shell_context_processor`.
from flask import Flask
app = Flask(__name__)
# Optional: Configure IPython settings via Flask app.config
app.config['IPYTHON_CONFIG'] = {
'InteractiveShell': {
'colors': 'Linux',
'confirm_exit': False,
},
}
@app.route('/')
def hello():
return "Hello, World!"
# To make your app and any models/database objects available in the shell context,
# define a shell context processor.
@app.shell_context_processor
def make_shell_context():
# In a real application, you would import your models and database instance here
# e.g., from .models import User, Post
# e.g., from .extensions import db
return dict(app=app, greeting="Hello from shell context!")
# To run the IPython shell, save this file as app.py (or your preferred name)
# and execute in your terminal:
# FLASK_APP=app.py flask shell
# You should see the IPython prompt, and 'app' and 'greeting' will be available.
flask --version
Upgrade
Version history
Breaking-change detection hasn't run for this library yet.
Audit
Security & dependencies
CVE tracking and dependency tree are planned for a later release.