micropip icon indicating copy to clipboard operation
micropip copied to clipboard

ENH: A micropip.main() for %pip in Jupyter

Open westurner opened this issue 9 months ago • 1 comments

STORY: Users can use %pip to install with micropip in JupyterLite notebooks (so that notebooks with %pip will work with all Python Jupyter kernels)


%pip  # works in jupyter_console, jupyter notebook, jupyterlab, but not in JupyterLite
!pip  # doesn't work in pyodide (because there's no $SHELL; jupyterlite/jupyterlite#949)

# Works with the pyodide Jupyter kernel but not ipykernel or xeus-python:
import micropip
await micropip.install(["pandas",])

A main for %pip would need or could have at least:

def test_micropip_main_help_version(capsys):
    assert micropip.main(["-h"]) == 0    
    assert micropip.main(["--help"]) == 0
    captured = capsys.readouterr()
    assert "micropip" in captured.out

    assert micropip.main(["--version"]) == 0
    captured = capsys.readouterr()
    assert "micropip" in captured.out

def test_micropip_main_install(capsys):
    assert micropip.main(["install", "testpkg"]) == 0

##

def test_micropip_main_list(capsys):
    assert micropip.main(["list"]) == 0

def test_micropip_main_freeze(capsys):
    assert micropip.main(["freeze"]) == 0

westurner avatar Sep 11 '23 05:09 westurner