Registry / web-framework / flask-shell-ipython

flask-shell-ipython

JSON →
library0.5.3pypypi✓ verified 25d ago

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.

pip install flask-shell-ipython
INSTALL
IMPORT
SIG · FLASK-SHELL-IPYTHO
F
flask-shell-ipython
web-frameworkpythonv0.5.3
Install
5.9s avg
Import
Disk
77MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
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
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 85MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 5.9s · import 0.000s · 85MB
77MB installed
● package 77MB
Code
Verified usage

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

Automatic Integration
No explicit import needed; installation automatically replaces `flask shell`.
from flask_shell_ipython import FlaskShellIPython; FlaskShellIPython.init_app(app)
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.

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
Debug
Known issues
gotchaUnlike many Flask extensions, `flask-shell-ipython` requires no explicit import or `init_app` call. Its functionality automatically replaces the `flask shell` command upon installation. Attempting to import or initialize it manually is unnecessary and will not yield the expected results.
fix
Simply install the package using `pip install flask-shell-ipython`. Then, run your Flask application's shell via `FLASK_APP=your_app.py flask shell`.
affects: All versions
gotchaEnsure your Python and Flask versions are compatible. `flask-shell-ipython` requires Python `>=3.8, <4.0`. Be mindful of Flask's own deprecations and minimum version requirements (e.g., Flask 2.0 dropped Python 2/3.5, Flask 3.0 requires Werkzeug >= 3.0), as these can indirectly affect `flask-shell-ipython`'s operational environment.
fix
Always check the `requires_python` metadata on PyPI for `flask-shell-ipython` and consult Flask's changelog to ensure compatibility with your project's Python and Flask versions. Upgrade components as necessary.
affects: All versions; depends on surrounding ecosystem.
gotchaWhen testing `flask-shell-ipython` (or applications using it) on Windows, be aware that the `pytest-forked` plugin, which is often recommended for ensuring isolated IPython instances during testing, does not work.
fix
On Windows, consider running tests manually for each test case or using a different testing approach that does not rely on `pytest-forked` for IPython instance isolation.
affects: All versions
Upgrade
Version history
0.5.3latest on PyPI · released Sep 5, 2024
Audit
Dependencies
FlaskrequiredThis package is a Flask extension and depends on Flask for its core functionality.
IPythonrequiredProvides the enhanced interactive shell features that this package integrates with Flask.
Agent activity
5 hits · last 30 days
node
4
Resources
flask-shell-ipython — pip install flask-shell-ipython · libregistry