IPython Kernel Executor
A lightweight Python package to execute code in an isolated IPython kernel and capture results, stdout, and stderr.
Supports Python 2+.
Installation
Make sure you have jupyter-client and ipykernel installed:
pip install jupyter-client ipykernel
Then, install this package:
pip install ipython-kernel-executor
Usage
Basic Execution
from __future__ import print_function
from ipython_kernel_executor import IPythonKernelExecutor
with IPythonKernelExecutor() as executor:
# Captures result
result, stdout, stderr = executor("1 + 1")
print(repr(result)) # '2'
print(repr(stdout)) # ''
print(repr(stderr)) # ''
# Captures stdout
result, stdout, stderr = executor("print('Hello, World!')")
print(repr(result)) # ''
print(repr(stdout)) # 'Hello, World!\n'
print(repr(stderr)) # ''
# Captures stderr
result, stdout, stderr = executor("1 / 0")
print(repr(result)) # ''
print(repr(stdout)) # ''
print(repr(stderr)) # contains 'ZeroDivisionError'
Manual Shutdown (Optional)
If not using with, manually shut down the kernel:
executor = IPythonKernelExecutor()
result, stdout, stderr = executor("2 * 3")
executor.shutdown() # Clean up
Contributing
Contributions are welcome! Please submit pull requests or open issues on GitHub.
License
This project is licensed under the MIT License. See the LICENSE file for details.
Metadata
Release files for ipython-kernel-executor 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| ipython_kernel_executor-0.1.1.tar.gz | 3.3 kB | Without provenance | Details for ipython_kernel_executor-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ipython_kernel_executor-0.1.1-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details for ipython_kernel_executor-0.1.1-py2.py3-none-any.whl |
Total release size: 7.0 kB
Release files / ipython_kernel_executor-0.1.1.tar.gz
| Download URL | ipython_kernel_executor-0.1.1.tar.gz |
|---|---|
| Size | 3.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3b6ee6872b5995099c2e83888793c4f28f3aeede451a5d6cfa70d30c1eefa5a8
|
|
BLAKE2b-256 checksum How to use checksums |
dc019adefcd89523b2a0d264eb7830a7547d2a07868f4faf73819b408745005a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.2
|
Release files / ipython_kernel_executor-0.1.1-py2.py3-none-any.whl
| Download URL | ipython_kernel_executor-0.1.1-py2.py3-none-any.whl |
|---|---|
| Size | 3.7 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
251d4f8c37bc5a02f12ac426518f5d44cb3a9d89a3131d2fd6683da2698bfde2
|
|
BLAKE2b-256 checksum How to use checksums |
0dde4f1b9d233a88a83e9865817f308d57b6d13b39f1c2d185ce26083f6c322a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.2
|
Security for ipython-kernel-executor 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.