Skip to content

A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.

feat: package installation from pypi (#961)

Akshay Agrawald9fbeb8b6313
diff --git a/frontend/src/components/editor/package-alert.tsx b/frontend/src/components/editor/package-alert.tsx
new file mode 100644
index 0000000000..821b31e58c
--- /dev/null
+++ b/frontend/src/components/editor/package-alert.tsx
@@ -0,0 +1,251 @@
+/* Copyright 2024 Marimo. All rights reserved. */
+
+import { cn } from "@/utils/cn";
+import { RuntimeState } from "@/core/kernel/RuntimeState";
+import { sendInstallMissingPackages } from "@/core/network/requests";
+import {
+ useAlerts,
+ useAlertActions,
+ MissingPackageAlert,
+ InstallingPackageAlert,
+ isMissingPackageAlert,
+ isInstallingPackageAlert,
+} from "@/core/alerts/state";
+import { Banner } from "@/plugins/impl/common/error-banner";
+import {
+ PackageXIcon,
+ BoxIcon,
+ CheckIcon,
+ DownloadCloudIcon,
+ PackageCheckIcon,
+ XIcon,
+} from "lucide-react";
+import React from "react";
+import { Button } from "../ui/button";
+import { PackageInstallationStatus } from "@/core/kernel/messages";
+import { logNever } from "@/utils/assertNever";
+
+export const PackageAlert: React.FC = (props) => {
+ const { packageAlert } = useAlerts();
+ const { addPackageAlert, clearPackageAlert } = useAlertActions();
+
+ if (packageAlert === null) {
+ return null;
+ }
+
+ if (isMissingPackageAlert(packageAlert)) {
+ return (
+ <div className="flex flex-col gap-4 mb-5 fixed top-5 left-5 w-[400px] z-[200] opacity-95">
+ <Banner
+ kind="danger"
+ className="flex flex-col rounded py-3 px-5 animate-in slide-in-from-left"
+ >
+ <div className="flex justify-between">
+ <span className="font-bold text-lg flex items-center mb-2">
+ <PackageXIcon className="w-5 h-5 inline-block mr-2" />
+ Missing packages
+ </span>
+ <Button
+ variant="text"
+ size="icon"
+ onClick={() => clearPackageAlert(packageAlert.id)}
+ >
+ <XIcon className="w-5 h-5" />
+ </Button>
+ </div>
+ <div className="flex flex-col gap-4 justify-between items-start text-muted-foreground text-base">
+ <div>
+ <p>The following packages were not found:</p>
+ <ul className="list-disc ml-4 mt-1">
+ {packageAlert.packages.map((pkg, index) => (
+ <li
+ className="flex items-center gap-1 font-mono text-sm"
+ key={index}
+ >
+ <BoxIcon size="1rem" />
+ {pkg}
+ </li>
+ ))}
+ </ul>
+ </div>
+ <div className="ml-auto">
+ {packageAlert.isolated ? (
+ <InstallPackagesButton
+ packages={packageAlert.packages}
+ addPackageAlert={addPackageAlert}
+ />
+ ) : (
+ <p>
+ If you set up a{" "}
+ <a
+ href="https://docs.python.org/3/tutorial/venv.html#creating-virtual-environments"
+ className="text-accent-foreground hover:underline"
+ target="_blank"
+ rel="noreferrer"
+ >
+ virtual environment
+ </a>
+ , marimo can install these packages for you.
+ </p>
+ )}
+ </div>
+ </div>
+ </Banner>
+ </div>
+ );
+ } else if (isInstallingPackageAlert(packageAlert)) {
+ const { status, title, titleIcon, description } =
+ getInstallationStatusElements(packageAlert.packages);
+ if (status === "installed") {
+ setTimeout(() => clearPackageAlert(packageAlert.id), 10_000);
+ }
+
+ return (
+ <div className="flex flex-col gap-4 mb-5 fixed top-5 left-5 w-[400px] z-[200] opacity-95">
+ <Banner
+ kind={status === "failed" ? "danger" : "info"}
+ className="flex flex-col rounded pt-3 pb-4 px-5"
+ >
+ <div className="flex justify-between">
+ <span className="font-bold text-lg flex items-center mb-2">
+ {titleIcon}
+ {title}
+ </span>
+ <Button
+ variant="text"
+ size="icon"
+ onClick={() => clearPackageAlert(packageAlert.id)}
+ >
+ <XIcon className="w-5 h-5" />
+ </Button>
+ </div>
+ <div
+ className={cn(
+ "flex flex-col gap-4 justify-between items-start text-muted-foreground text-base",
+ status === "installed" && "text-accent-foreground",
+ )}
+ >
+ <div>
+ <p>{description}</p>
+ <ul className="list-disc ml-4 mt-1">
+ {Object.entries(packageAlert.packages).map(
+ ([pkg, st], index) => (
+ <li
+ className={cn(
+ "flex items-center gap-1 font-mono text-sm",
+ st === "installing" && "font-semibold",
+ st === "failed" && "text-destructive",
+ st === "installed" && "text-accent-foreground",
+ st === "installed" &&
+ status === "failed" &&
+ "text-muted-foreground",
+ )}
+ key={index}
+ >
+ <ProgressIcon status={st} />
+ {pkg}
+ </li>
+ ),
+ )}
+ </ul>
+ </div>
+ </div>
+ </Banner>
+ </div>
+ );
+ } else {
+ logNever(packageAlert);
+ return null;
+ }
+};
+
+function getInstallationStatusElements(packages: PackageInstallationStatus) {
+ const statuses = new Set(Object.values(packages));
+ const status =
+ statuses.has("queued") || statuses.has("installing")
+ ? "installing"
+ : statuses.has("failed")
+ ? "failed"
+ : "installed";
+
+ if (status === "installing") {
+ return {
+ status: "installing",
+ title: "Installing packages",
+ titleIcon: <DownloadCloudIcon className="w-5 h-5 inline-block mr-2" />,
+ description: "Installing packages:",
+ };
+ } else if (status === "installed") {
+ return {
+ status: "installed",
+ title: "All packages installed!",
+ titleIcon: <PackageCheckIcon className="w-5 h-5 inline-block mr-2" />,
+ description: "Installed packages:",
+ };
+ } else {
+ return {
+ status: "failed",
+ title: "Some packages failed to install",
+ titleIcon: <PackageXIcon className="w-5 h-5 inline-block mr-2" />,
+ description: "See terminal for error logs.",
+ };
+ }
+}
+
+const ProgressIcon = ({
+ status,
+}: {
+ status: PackageInstallationStatus[string];
+}) => {
+ switch (status) {
+ case "queued":
+ return <BoxIcon size="1rem" />;
+ case "installing":
+ return <DownloadCloudIcon size="1rem" />;
+ case "installed":
+ return <CheckIcon size="1rem" />;
+ case "failed":
+ return <XIcon size="1rem" />;
+ default:
+ logNever(status);
+ return null;
+ }
+};
+
+async function installPackages(
+ packages: string[],
+ addPackageAlert: (
+ alert: MissingPackageAlert | InstallingPackageAlert,
+ ) => void,
+) {
+ const packageStatus = Object.fromEntries(
+ packages.map((pkg) => [pkg, "queued"]),
+ ) as PackageInstallationStatus;
+ addPackageAlert({
+ kind: "installing",
+ packages: packageStatus,
+ });
+ RuntimeState.INSTANCE.registerRunStart();
+ await sendInstallMissingPackages({ manager: "pip" });
+}
+
+const InstallPackagesButton = ({
+ packages,
+ addPackageAlert,
+}: {
+ packages: string[];
+ addPackageAlert: (
+ alert: MissingPackageAlert | InstallingPackageAlert,
+ ) => void;
+}) => {
+ return (
+ <Button
+ variant="outline"
+ size="sm"
+ onClick={() => installPackages(packages, addPackageAlert)}
+ >
+ <DownloadCloudIcon className="w-4 h-4 mr-2" />
+ <span className="font-semibold">Install with pip</span>
+ </Button>
+ );
+};
diff --git a/frontend/src/components/editor/renderers/CellArray.tsx b/frontend/src/components/editor/renderers/CellArray.tsx
index 4bedf04e51..1854c5ab80 100644
--- a/frontend/src/components/editor/renderers/CellArray.tsx
+++ b/frontend/src/components/editor/renderers/CellArray.tsx
@@ -22,6 +22,7 @@ import { useDelayVisibility } from "./vertical-layout/useDelayVisibility";
import { useChromeActions } from "../chrome/state";
import { Functions } from "@/utils/functions";
import { NotebookBanner } from "../notebook-banner";
+import { PackageAlert } from "@/components/editor/package-alert";
interface CellArrayProps {
notebook: NotebookState;
@@ -97,6 +98,7 @@ export const CellArray: React.FC<CellArrayProps> = ({
invisible={invisible}
appConfig={appConfig}
>
+ <PackageAlert />
<NotebookBanner />
{cells.map((cell) => (
<Cell
diff --git a/frontend/src/components/ui/button.tsx b/frontend/src/components/ui/button.tsx
index 5b0b7749ca..71c416a5c2 100644
--- a/frontend/src/components/ui/button.tsx
+++ b/frontend/src/components/ui/button.tsx
@@ -46,9 +46,9 @@ const buttonVariants = cva(
activeCommon,
),
outline: cn(
- "border border-slate-500 shadow-smSolid",
- "hover:bg-secondary/90 hover:text-secondary-foreground",
- "hover:border-input",
+ "border border-slate-300 shadow-smSolid",
+ "hover:bg-accent hover:text-accent-foreground",
+ "hover:border-primary",
activeCommon,
),
secondary: cn(
diff --git a/frontend/src/core/alerts/state.ts b/frontend/src/core/alerts/state.ts
new file mode 100644
index 0000000000..385778c450
--- /dev/null
+++ b/frontend/src/core/alerts/state.ts
@@ -0,0 +1,86 @@
+/* Copyright 2024 Marimo. All rights reserved. */
+
+import { PackageInstallationStatus } from "@/core/kernel/messages";
+import { createReducer } from "@/utils/createReducer";
+import { generateUUID } from "@/utils/uuid";
+import { atom, useAtomValue, useSetAtom } from "jotai";
+import { useMemo } from "react";
+
+type Identified<T> = { id: string } & T;
+
+export interface MissingPackageAlert {
+ kind: "missing";
+ packages: string[];
+ isolated: boolean;
+}
+
+export interface InstallingPackageAlert {
+ kind: "installing";
+ packages: PackageInstallationStatus;
+}
+
+export function isMissingPackageAlert(
+ alert: MissingPackageAlert | InstallingPackageAlert,
+): alert is MissingPackageAlert {
+ return alert.kind === "missing";
+}
+
+export function isInstallingPackageAlert(
+ alert: MissingPackageAlert | InstallingPackageAlert,
+): alert is InstallingPackageAlert {
+ return alert.kind === "installing";
+}
+
+/** Prominent alerts.
+ *
+ * Right now we only have one type of alert.
+ */
+interface AlertState {
+ packageAlert:
+ | Identified<MissingPackageAlert>
+ | Identified<InstallingPackageAlert>
+ | null;
+}
+
+const { reducer, createActions } = createReducer(
+ () => ({ packageAlert: null }) as AlertState,
+ {
+ addPackageAlert: (
+ state,
+ alert: MissingPackageAlert | InstallingPackageAlert,
+ ) => {
+ return {
+ ...state,
+ packageAlert: { id: generateUUID(), ...alert },
+ };
+ },
+
+ clearPackageAlert: (state, id: string) => {
+ return state.packageAlert !== null && state.packageAlert.id === id
+ ? { ...state, packageAlert: null }
+ : state;
+ },
+ },
+);
+
+const alertAtom = atom<AlertState>({
+ packageAlert: null,
+});
+
+/**
+ * React hook to get the Alert state.
+ */
+export const useAlerts = () => useAtomValue(alertAtom);
+
+/**
+ * React hook to get the Alerts actions.
+ */
+export function useAlertActions() {
+ const setState = useSetAtom(alertAtom);
+ return useMemo(() => {
+ const actions = createActions((action) => {
+ setState((state) => reducer(state, action));
+ });
+ return actions;
+ }, [setState]);
+}
diff --git a/frontend/src/core/kernel/messages.ts b/frontend/src/core/kernel/messages.ts
index 1cbd111e9d..d7d751fc14 100644
--- a/frontend/src/core/kernel/messages.ts
+++ b/frontend/src/core/kernel/messages.ts
@@ -155,6 +155,13 @@ export interface FunctionCallResultMessage {
status: HumanReadableStatus;
}
+export interface PackageInstallationStatus {
+ /**
+ * Package name => status
+ */
+ [key: string]: "queued" | "installing" | "installed" | "failed";
+}
+
/**
* Message sent from the frontend to the kernel via the websocket.
*/
@@ -260,6 +267,7 @@ export type OperationMessage =
};
}
| {
+ // transient toast / alert
op: "alert";
data: {
title: string;
@@ -268,6 +276,24 @@ export type OperationMessage =
};
}
| {
+ // permanent alert (requires action)
+ op: "missing-package-alert";
+ data: {
+ kind: "missing";
+ packages: string[];
+ isolated: boolean;
+ };
+ }
+ | {
+ // permanent alert (requires action)
+ op: "installing-package-alert";
+ data: {
+ kind: "installing";
+ packages: PackageInstallationStatus;
+ };
+ }
+ | {
+ // permanent notification
op: "banner";
data: {
title: string;
diff --git a/frontend/src/core/network/requests.ts b/frontend/src/core/network/requests.ts
index 05cf4f8cc0..cae8f7ddec 100644
--- a/frontend/src/core/network/requests.ts
+++ b/frontend/src/core/network/requests.ts
@@ -22,6 +22,7 @@ import {
RunRequests,
EditRequests,
SendStdin,
+ SendInstallMissingPackages,
FileListResponse,
FileCreateRequest,
FileOperationResponse,
@@ -136,6 +137,12 @@ function createNetworkRequests(): EditRequests & RunRequests {
sendStdin: (request) => {
return API.post<SendStdin>("/kernel/stdin", request);
},
+ sendInstallMissingPackages: (request) => {
+ return API.post<SendInstallMissingPackages>(
+ "/kernel/install_missing_packages",
+ request,
+ );
+ },
readCode: () => {
return API.post<{}, { contents: string }>("/kernel/read_code", {});
},
@@ -195,6 +202,7 @@ export const {
saveAppConfig,
saveCellConfig,
sendFunctionRequest,
+ sendInstallMissingPackages,
readCode,
openFile,
sendListFiles,
diff --git a/frontend/src/core/network/static-requests.ts b/frontend/src/core/network/static-requests.ts
index 8593dfd56c..640e795671 100644
--- a/frontend/src/core/network/static-requests.ts
+++ b/frontend/src/core/network/static-requests.ts
@@ -56,5 +56,6 @@ export function createStaticRequests(): EditRequests & RunRequests {
sendDeleteFileOrFolder: throwNotInEditMode,
sendRenameFileOrFolder: throwNotInEditMode,
sendFileDetails: throwNotInEditMode,
+ sendInstallMissingPackages: throwNotInEditMode,
};
}
diff --git a/frontend/src/core/network/types.ts b/frontend/src/core/network/types.ts
index d897141bbc..03599c6df4 100644
--- a/frontend/src/core/network/types.ts
+++ b/frontend/src/core/network/types.ts
@@ -94,6 +94,11 @@ export interface SendStdin {
text: string;
}
+// In the future may include things like package manager, index URL, ...
+export interface SendInstallMissingPackages {
+ manager: "pip";
+}
+
export interface ValueUpdate {
objectId: string;
value: unknown;
@@ -172,6 +177,9 @@ export interface EditRequests {
saveAppConfig: (request: SaveAppConfigRequest) => Promise<null>;
saveCellConfig: (request: SaveCellConfigRequest) => Promise<null>;
sendRestart: () => Promise<null>;
+ sendInstallMissingPackages: (
+ request: SendInstallMissingPackages,
+ ) => Promise<null>;
readCode: () => Promise<{ contents: string }>;
openFile: (request: { path: string }) => Promise<null>;
// File explorer requests
diff --git a/frontend/src/core/pyodide/bridge.ts b/frontend/src/core/pyodide/bridge.ts
index 36c902a5f3..6d490e12af 100644
--- a/frontend/src/core/pyodide/bridge.ts
+++ b/frontend/src/core/pyodide/bridge.ts
@@ -21,6 +21,7 @@ import {
SaveKernelRequest,
SaveUserConfigRequest,
SendFunctionRequest,
+ SendInstallMissingPackages,
SendStdin,
ValueUpdate,
} from "../network/types";
@@ -191,7 +192,12 @@ export class PyodideBridge implements RunRequests, EditRequests {
});
return null;
};
-
+ sendInstallMissingPackages = async (
+ request: SendInstallMissingPackages,
+ ): Promise<null> => {
+ this.putControlRequest(request);
+ return null;
+ };
sendCodeCompletionRequest = async (
request: CodeCompletionRequest,
): Promise<null> => {
diff --git a/frontend/src/core/websocket/useMarimoWebSocket.tsx b/frontend/src/core/websocket/useMarimoWebSocket.tsx
index da753d8e83..659bef4b77 100644
--- a/frontend/src/core/websocket/useMarimoWebSocket.tsx
+++ b/frontend/src/core/websocket/useMarimoWebSocket.tsx
@@ -28,6 +28,7 @@ import { VirtualFileTracker } from "../static/virtual-file-tracker";
import { Objects } from "@/utils/objects";
import { SessionId } from "../kernel/session";
import { useBannersActions } from "../errors/state";
+import { useAlertActions } from "../alerts/state";
import { generateUUID } from "@/utils/uuid";
/**
@@ -49,6 +50,7 @@ export function useMarimoWebSocket(opts: {
const setLayoutData = useSetAtom(layoutDataAtom);
const [connStatus, setConnStatus] = useAtom(connectionAtom);
const { addBanner } = useBannersActions();
+ const { addPackageAlert } = useAlertActions();
const handleMessage = (e: MessageEvent<string>) => {
const msg = jsonParseWithSpecialChar<OperationMessage>(e.data);
@@ -204,6 +206,20 @@ export function useMarimoWebSocket(opts: {
id: generateUUID(),
});
return;
+ case "missing-package-alert":
+ addPackageAlert({
+ ...msg.data,
+ kind: "missing",
+ });
+ return;
+ case "installing-package-alert":
+ console.log("package alert");
+ console.log(msg.data);
+ addPackageAlert({
+ ...msg.data,
+ kind: "installing",
+ });
+ return;
default:
logNever(msg);
}
diff --git a/frontend/src/css/globals.css b/frontend/src/css/globals.css
index a3980a1318..b16f339b42 100644
--- a/frontend/src/css/globals.css
+++ b/frontend/src/css/globals.css
@@ -94,6 +94,8 @@
0px 0px 4px 0px var(--stale-color);
--heavy-shadow-error: 7px 8px 0px 0px var(--red-8),
0px 0px 2px 0px var(--red-8);
+ --light-shadow-accent: 4px 4px 0px 0px hsl(var(--accent)),
+ 0px 0px 2px 0px hsl(var(--accent));
}
.dark {
diff --git a/frontend/src/plugins/impl/common/error-banner.tsx b/frontend/src/plugins/impl/common/error-banner.tsx
index cbbbf765dd..586826cfc5 100644
--- a/frontend/src/plugins/impl/common/error-banner.tsx
+++ b/frontend/src/plugins/impl/common/error-banner.tsx
@@ -58,8 +58,8 @@ export const ErrorBanner = ({
const bannerStyle = cva("text-sm p-2 border whitespace-pre-wrap", {
variants: {
kind: {
- danger: `text-error border-[var(--red-6)] bg-[var(--red-2)]`,
- info: `text-primary border-[var(--blue-6)] bg-[var(--blue-2)]`,
+ danger: `text-error border-[var(--red-6)] shadow-smError bg-[var(--red-1)]`,
+ info: `text-primary border-[var(--blue-6)] shadow-smAccent bg-[var(--blue-1)]`,
warn: `text-warning border-[var(--yellow-6)] bg-[var(--yellow-2)]`,
},
clickable: {
diff --git a/frontend/tailwind.config.js b/frontend/tailwind.config.js
index 18c5c114cb..9eea6af4dd 100644
--- a/frontend/tailwind.config.js
+++ b/frontend/tailwind.config.js
@@ -41,8 +41,9 @@ module.exports = {
smNeutral: "var(--light-shadow)",
mdNeutral: "var(--medium-shadow)",
lgNeutral: "var(--heavy-shadow)",
- // error shadows
+ // accent/error shadows
smError: "var(--light-shadow-error)",
+ smAccent: "var(--light-shadow-accent)",
},
maxWidth: {
contentWidth: "var(--content-width)",
diff --git a/marimo/_ast/cell.py b/marimo/_ast/cell.py
index 1b5a34214e..b1cec9aa23 100644
--- a/marimo/_ast/cell.py
+++ b/marimo/_ast/cell.py
@@ -124,6 +124,20 @@ class CellImpl:
if data.module is not None
)
+ def module_to_variable(self, module: str) -> Name | None:
+ """Returns the variable name corresponding to an imported module
+
+ Relevant for imports "as" imports, eg
+
+ import matplotlib.pyplot as plt
+
+ In this case the module is "matplotlib" but the name is "plt".
+ """
+ for name, data in self.variable_data.items():
+ if data.module == module:
+ return name
+ return None
+
def is_coroutine(self) -> bool:
return _is_coroutine(self.body) or _is_coroutine(self.last_expr)
diff --git a/marimo/_messaging/ops.py b/marimo/_messaging/ops.py
index 7e1e67e4bf..9b925e02e0 100644
--- a/marimo/_messaging/ops.py
+++ b/marimo/_messaging/ops.py
@@ -287,6 +287,25 @@ class Alert(Op):
variant: Optional[Literal["danger"]] = None
+@dataclass
+class MissingPackageAlert(Op):
+ name: ClassVar[str] = "missing-package-alert"
+ packages: List[str]
+ isolated: bool
+
+
+# package name => installation status
+PackageStatusType = Dict[
+ str, Literal["queued", "installing", "installed", "failed"]
+]
+
+
+@dataclass
+class InstallingPackageAlert(Op):
+ name: ClassVar[str] = "installing-package-alert"
+ packages: PackageStatusType
+
+
@dataclass
class Reconnected(Op):
name: ClassVar[str] = "reconnected"
@@ -380,6 +399,8 @@ MessageOperation = Union[
CompletionResult,
Alert,
Banner,
+ MissingPackageAlert,
+ InstallingPackageAlert,
Variables,
VariableValues,
]
diff --git a/marimo/_pyodide/pyodide_session.py b/marimo/_pyodide/pyodide_session.py
index 6f56593543..81907c9883 100644
--- a/marimo/_pyodide/pyodide_session.py
+++ b/marimo/_pyodide/pyodide_session.py
@@ -22,6 +22,9 @@ from marimo._runtime import handlers, requests
from marimo._runtime.context import initialize_context
from marimo._runtime.input_override import input_override
from marimo._runtime.marimo_pdb import MarimoPdb
+from marimo._runtime.packages.pypi_package_manager import (
+ MicropipPackageManager,
+)
from marimo._runtime.requests import (
AppMetadata,
CompletionRequest,
@@ -323,6 +326,7 @@ def launch_pyodide_kernel(
stdin=stdin,
input_override=input_override,
debugger_override=debugger,
+ package_manager=MicropipPackageManager(),
)
initialize_context(
kernel=kernel,
diff --git a/marimo/_runtime/cell_runner.py b/marimo/_runtime/cell_runner.py
index 541b3399c5..ab3eb837d4 100644
--- a/marimo/_runtime/cell_runner.py
+++ b/marimo/_runtime/cell_runner.py
@@ -248,6 +248,9 @@ class Runner:
# - KeyboardInterrupt shouldn't be raised, since marimo
# redirects it to a MarimoInterrupt
# - SystemExit should kill the process
+ if isinstance(e, ModuleNotFoundError):
+ self.missing_packages = True
+
self.cancel(cell_id)
run_result = RunResult(output=None, exception=e)
traceback.print_exc(file=sys.stderr)
diff --git a/marimo/_runtime/packages/module_name_to_pypi_name.py b/marimo/_runtime/packages/module_name_to_pypi_name.py
new file mode 100644
index 0000000000..e381c9ac6c
--- /dev/null
+++ b/marimo/_runtime/packages/module_name_to_pypi_name.py
@@ -0,0 +1,763 @@
+# Copyright 2024 Marimo. All rights reserved.
+from __future__ import annotations
+
+# Mapping from a module name to the corresponding package name # on PyPI
+
+
+def module_name_to_pypi_name() -> dict[str, str]:
+ return {
+ "shopify": "ShopifyAPI",
+ "bigquery": "google-cloud-bigquery",
+ "carbon3d": "carbon3d-client",
+ "telegram": "python-telegram-bot",
+ "AFQ": "pyAFQ",
+ "AG_fft_tools": "agpy",
+ "screen": "pexpect",
+ "Adafruit": "Adafruit-Libraries",
+ "webdav": "Zope2",
+ "Asterisk": "py-Asterisk",
+ "BB_jekyll_hook": "bitbucket-jekyll-hook",
+ "Banzai": "Banzai-NGS",
+ "BeautifulSoupTests": "BeautifulSoup",
+ "BioSQL": "biopython",
+ "BuildbotStatusShields": "BuildbotEightStatusShields",
+ "MethodObject": "ExtensionClass",
+ "Crypto": "pycryptodome",
+ "Cryptodome": "pycryptodomex",
+ "FiftyOneDegrees": "51degrees-mobile-detector-v3-wrapper",
+ "functional": "pyfunctional",
+ "GeoBases": "GeoBasesDev",
+ "IPython": "ipython",
+ "Kittens": "astro-kittens",
+ "Levenshtein": "python-Levenshtein",
+ "MySQLdb": "MySQL-python",
+ "OpenGL": "PyOpenGL",
+ "OpenSSL": "pyOpenSSL",
+ "PIL": "Pillow",
+ "PyWCSTools": "astLib",
+ "Pyxides": "astro-pyxis",
+ "pysideuic": "PySide",
+ "S3": "s3cmd",
+ "SCons": "pystick",
+ "Stemmer": "PyStemmer",
+ "TopZooTools": "topzootools",
+ "TreeDisplay": "DocumentTemplate",
+ "WorkingWithDocumentConversion": "aspose-pdf-java-for-python",
+ "aadb": "auto-adjust-display-brightness",
+ "abakaffe": "abakaffe-cli",
+ "abiosgaming": "abiosgaming.py",
+ "abiquo": "abiquo-api",
+ "abl": "abl.vpath",
+ "abo": "abo-generator",
+ "abris_transform": "abris",
+ "abstract": "abstract.jwrotator",
+ "abu": "abu.admin",
+ "ac_flask": "AC-Flask-HipChat",
+ "acg": "anikom15",
+ "acme": "acme.hello",
+ "acted": "acted.projects",
+ "action": "ActionServer",
+ "actionbar": "actionbar.panel",
+ "activehomed": "afn",
+ "activepapers": "ActivePapers.Py",
+ "address_book": "address-book-lansry",
+ "adi": "adi.trash",
+ "adict": "aDict2",
+ "aditam": "aditam.core",
+ "adiumsh": "adium-sh",
+ "adjector": "AdjectorTracPlugin",
+ "adkit": "Banner-Ad-Toolkit",
+ "admin_tools": "django-admin-tools",
+ "adminishcategories": "adminish-categories",
+ "adminsortable": "django-admin-sortable",
+ "adspygoogle": "adspygoogle.adwords",
+ "advancedcaching": "agtl",
+ "adytum": "Adytum-PyMonitor",
+ "affinitic": "affinitic.zamqp",
+ "afpy": "afpy.xap",
+ "agatesql": "agate-sql",
+ "ageliaco": "ageliaco.recipe.csvconfig",
+ "agent_http": "agent.http",
+ "agora": "Agora-Service-Provider",
+ "agoraplex": "agoraplex.themes.sphinx",
+ "agsci": "agsci.blognewsletter",
+ "agx": "agx.transform.xmi2uml",
+ "aimes": "aimes.skeleton",
+ "aio": "aio.signals",
+ "aiohs2": "aio-hs2",
+ "aioroutes": "aio-routes",
+ "aios3": "aio-s3",
+ "airbrake": "airbrake-flask",
+ "airship": "airship-steamcloud",
+ "akamai": "edgegrid-python",
+ "alation": "alation-api",
+ "alba_client": "alba-client-python",
+ "alburnum": "alburnum-maas-client",
+ "alchemist": "alchemist.ui",
+ "alchemyapi": "alchemyapi-python",
+ "alerta": "alerta-server",
+ "alexandria_upload": "Alexandria-Upload-Utils",
+ "alibaba": "alibaba-python-sdk",
+ "aliyun": "aliyun-python-sdk",
+ "aliyuncli": "alicloudcli",
+ "aliyunsdkacs": "aliyun-python-sdk-acs",
+ "aliyunsdkbatchcompute": "aliyun-python-sdk-batchcompute",
+ "aliyunsdkbsn": "aliyun-python-sdk-bsn",
+ "aliyunsdkbss": "aliyun-python-sdk-bss",
+ "aliyunsdkcdn": "aliyun-python-sdk-cdn",
+ "aliyunsdkcms": "aliyun-python-sdk-cms",
+ "aliyunsdkcore": "aliyun-python-sdk-core",
+ "aliyunsdkcrm": "aliyun-python-sdk-crm",
+ "aliyunsdkcs": "aliyun-python-sdk-cs",
+ "aliyunsdkdrds": "aliyun-python-sdk-drds",
+ "aliyunsdkecs": "aliyun-python-sdk-ecs",
+ "aliyunsdkess": "aliyun-python-sdk-ess",
+ "aliyunsdkft": "aliyun-python-sdk-ft",
+ "aliyunsdkmts": "aliyun-python-sdk-mts",
+ "aliyunsdkocs": "aliyun-python-sdk-ocs",
+ "aliyunsdkoms": "aliyun-python-sdk-oms",
+ "aliyunsdkossadmin": "aliyun-python-sdk-ossadmin",
+ "aliyunsdkr-kvstore": "aliyun-python-sdk-r-kvstore",
+ "aliyunsdkram": "aliyun-python-sdk-ram",
+ "aliyunsdkrds": "aliyun-python-sdk-rds",
+ "aliyunsdkrisk": "aliyun-python-sdk-risk",
+ "aliyunsdkros": "aliyun-python-sdk-ros",
+ "aliyunsdkslb": "aliyun-python-sdk-slb",
+ "aliyunsdksts": "aliyun-python-sdk-sts",
+ "aliyunsdkubsms": "aliyun-python-sdk-ubsms",
+ "aliyunsdkyundun": "aliyun-python-sdk-yundun",
+ "allattachments": "AllAttachmentsMacro",
+ "allocine": "allocine-wrapper",
+ "allowedsites": "django-allowedsites",
+ "alm": "alm.solrindex",
+ "aloft": "aloft.py",
+ "alpacalib": "alpaca",
+ "alphabetic": "alphabetic-simple",
+ "alphasms": "alphasms-client",
+ "altered": "altered.states",
+ "alterootheme": "alterootheme.lazydays",
+ "alurinium": "alurinium-image-processing",
+ "alxlib": "alx",
+ "amara3": "amara3-xml",
+ "amazon": "python-amazon-simple-product-api",
+ "ambikesh1349-1": "ambikesh1349-1",
+ "ambilight": "AmbilightParty",
+ "amifs": "amifs-core",
+ "amiorganizer": "ami-organizer",
+ "amitu": "amitu-zutils",
+ "amltlearn": "AMLT-learn",
+ "amocrm": "amocrm-api",
+ "amqpdispatcher": "amqp-dispatcher",
+ "amqpstorm": "AMQP-Storm",
+ "analytics": "analytics-python",
+ "analyzedir": "AnalyzeDirectory",
+ "ancientsolutions": "ancientsolutions-crypttools",
+ "anderson_paginator": "anderson.paginator",
+ "android_clean_app": "android-resource-remover",
+ "anel_power_control": "AnelPowerControl",
+ "angus": "angus-sdk-python",
+ "annalist_root": "Annalist",
+ "annogesiclib": "ANNOgesic",
+ "ansible-role-apply": "ansible-role-apply",
+ "ansibledebugger": "ansible-playbook-debugger",
+ "ansibledocgen": "ansible-docgen",
+ "ansibleflow": "ansible-flow",
+ "ansibleinventorygrapher": "ansible-inventory-grapher",
+ "ansiblelint": "ansible-lint",
+ "ansiblerolesgraph": "ansible-roles-graph",
+ "ansibletools": "ansible-tools",
+ "anthill": "anthill.tal.macrorenderer",
+ "anthrax": "AnthraxImage",
+ "antisphinx": "antiweb",
+ "antispoofing": "antispoofing.evaluation",
+ "antlr4": "antlr4-python-alt",
+ "anybox": "anybox.scripts.odoo",
+ "googleapiclient": "google-api-python-client",
+ "apitools": "google-apitools",
+ "apm": "arpm",
+ "app_data": "django-appdata",
+ "appconf": "django-appconf",
+ "appd": "AppDynamicsREST",
+ "appdynamics_bindeps": "appdynamics-bindeps-osx-x64",
+ "appdynamics_proxysupport": "appdynamics-proxysupport-osx-x64",
+ "appium": "Appium-Python-Client",
+ "appliapps": "applibase",
+ "appserver": "broadwick",
+ "archetypes": "archetypes.schemaextender",
+ "arm": "ansible-role-manager",
+ "armor": "armor-api",
+ "armstrong": "armstrong.utils.celery",
+ "arstecnica": "arstecnica.sqlalchemy.async",
+ "article-downloader": "article-downloader",
+ "artifactcli": "artifact-cli",
+ "arvados": "arvados-python-client",
+ "arvados_cwl": "arvados-cwl-runner",
+ "arvnodeman": "arvados-node-manager",
+ "asana_to_github": "AsanaToGithub",
+ "asciibinary": "AsciiBinaryConverter",
+ "asd": "AdvancedSearchDiscovery",
+ "askbot": "askbot-tuanpa",
+ "asnhistory": "asnhistory-redis",
+ "aspen_jinja2_renderer": "aspen-jinja2",
+ "aspen_tornado_engine": "aspen-tornado",
+ "asprise_ocr_api": "asprise-ocr-sdk-python-api",
+ "aspy": "aspy.yaml",
+ "asterisk": "asterisk-ami",
+ "asts": "add-asts",
+ "asymmetricbase": "asymmetricbase.utils",
+ "asyncirc": "asyncio-irc",
+ "asyncmongoorm": "asyncmongoorm-je",
+ "asyncssh": "asyncssh-unofficial",
+ "athletelist": "athletelistyy",
+ "atm": "automium",
+ "atmosphere": "atmosphere-python-client",
+ "atom": "gdata",
+ "atomic": "AtomicWrite",
+ "atomisator": "atomisator.readers",
+ "atreal": "atreal.usersinout",
+ "atsim": "atsim.potentials",
+ "attractsdk": "attract-sdk",
+ "audio": "audio.wave",
+ "aufrefer": "auf-refer",
+ "auslfe": "auslfe.formonline.content",
+ "auspost": "auspost-apis",
+ "auth0": "auth0-python",
+ "auth_server_client": "AuthServerClient",
+ "authorize": "AuthorizeSauce",
+ "authzpolicy": "AuthzPolicyPlugin",
+ "autobahn": "autobahn-rce",
+ "avatar": "geonode-avatar",
+ "awebview": "android-webview",
+ "azure": "azure-storage",
+ "b2gcommands": "b2g-commands",
+ "b2gperf": "b2gperf-v2.2",
+ "b2gpopulate": "b2gpopulate-v2.2",
+ "b3j0f": "b3j0f.utils",
+ "babel": "Babel",
+ "babelglade": "BabelGladeExtractor",
+ "backplane": "backplane2-pyclient",
+ "backport_abcoll": "backport-collections",
+ "backports": "backports.statistics",
+ "badgekit": "badgekit-api-client",
+ "badlinks": "BadLinksPlugin",
+ "bael": "bael.project",
+ "baidu": "baidupy",
+ "balrog": "buildtools",
+ "baluhn": "baluhn-redux",
+ "bamboo": "bamboo-server",
+ "bambu": "bambu-sites",
+ "banana": "banana.maya",
+ "bang": "bangtext",
+ "barcode": "barcode-generator",
+ "bark": "bark-ssg",
+ "barking_owl": "BarkingOwl",
+ "bart": "bart-py",
+ "basalt": "basalt-tasks",
+ "base62": "base-62",
+ "basemap": "basemap-Jim",
+ "bash": "bash-toolbelt",
+ "bashutils": "Python-Bash-Utils",
+ "basic_http": "BasicHttp",
+ "basil": "basil-daq",
+ "batchapps": "azure-batch-apps",
+ "bcrypt": "python-bcrypt",
+ "beaker": "Beaker",
+ "beetsplug": "beets",
+ "begin": "begins",
+ "benchit": "bench-it",
+ "beproud": "beproud.utils",
+ "bfillings": "burrito-fillings",
+ "pilot": "BigJob",
+ "billboard": "billboard.py",
+ "binstar_build_client": "anaconda-build",
+ "binstar_client": "anaconda-client",
+ "biocommons": "biocommons.dev",
+ "birdhousebuilder": "birdhousebuilder.recipe.supervisor",
+ "blender26-meshio": "pymeshio",
+ "borg": "borg.localrole",
+ "bow": "bagofwords",
+ "bpdb": "bpython",
+ "bqapi": "bisque-api",
+ "braces": "django-braces",
+ "briefscaster": "briefs-caster",
+ "brisa_media_server/plugins": "brisa-media-server-plugins",
+ "brkt_requests": "brkt-sdk",
+ "broadcastlogging": "broadcast-logging",
+ "brocadetool": "brocade-tool",
+ "bronto": "bronto-python",
+ "brownie": "Brownie",
+ "browsermobproxy": "browsermob-proxy",
+ "brubeckmysql": "brubeck-mysql",
+ "brubeckoauth": "brubeck-oauth",
+ "brubeckservice": "brubeck-service",
+ "brubeckuploader": "brubeck-uploader",
+ "bs4": "beautifulsoup4",
+ "gridfs": "pymongo",
+ "bst": "bst.pygasus.wsgi",
+ "btable": "btable-py",
+ "btapi": "bananatag-api",
+ "btceapi": "btce-api",
+ "btcebot": "btce-bot",
+ "btsync": "btsync.py",
+ "buck": "buck.pprint",
+ "bud": "bud.nospam",
+ "budy": "budy-api",
+ "buffer": "buffer-alpaca",
+ "buggd": "bug.gd",
+ "bugle": "bugle-sites",
+ "bugspots": "bug-spots",
+ "bugzilla": "python-bugzilla",
+ "bugzscout": "bugzscout-py",
+ "buildTools": "ajk-ios-buildTools",
+ "buildnotifylib": "BuildNotify",
+ "buildout": "buildout.variables",
+ "buildslave": "buildbot-slave",
+ "xmlrpc": "pies2overrides",
+ "bumper": "bumper-lib",
+ "bumple": "bumple-downloader",
+ "bundesliga": "bundesliga-cli",
+ "bundlemaker": "bundlemanager",
+ "burpui": "burp-ui",
+ "busyflow": "busyflow.pivotal",
+ "buttercms-django": "buttercms-django",
+ "buzz": "buzz-python-client",
+ "bvc": "buildout-versions-checker",
+ "bvggrabber": "bvg-grabber",
+ "byond": "BYONDTools",
+ "bzETL": "Bugzilla-ETL",
+ "bzlib": "bugzillatools",
+ "bzrlib": "bzr-pqm",
+ "c2c": "c2c.versions",
+ "c2c_recipe_facts": "c2c.recipe.facts",
+ "cabalgata": "cabalgata-zookeeper",
+ "cache_utils": "django-cache-utils",
+ "captcha": "django-recaptcha",
+ "cartridge": "Cartridge",
+ "cassandra": "cassandra-driver",
+ "cassandralauncher": "CassandraLauncher",
+ "cc42": "42qucc",
+ "cerberus": "Cerberus",
+ "cfnlint": "cfn-lint",
+ "chameleon": "Chameleon",
+ "charmtools": "charm-tools",
+ "chef": "PyChef",
+ "chip8": "c8d",
+ "cjson": "python-cjson",
+ "classytags": "django-classy-tags",
+ "cloghandler": "ConcurrentLogHandler",
+ "clonevirtualenv": "virtualenv-clone",
+ "cloud-insight": "al-cloudinsight",
+ "cloud_admin": "adminapi",
+ "cloudservers": "python-cloudservers",
+ "tasksitter": "cerebrod",
+ "cms": "django-cms",
+ "colander": "ba-colander",
+ "colors": "ansicolors",
+ "compile": "bf-lc3",
+ "compose": "docker-compose",
+ "compressor": "django-compressor",
+ "concurrent": "futures",
+ "configargparse": "ConfigArgParse",
+ "contracts": "PyContracts",
+ "weblogolib": "weblogo",
+ "couchapp": "Couchapp",
+ "couchdb": "CouchDB",
+ "couchdbcurl": "couchdb-python-curl",
+ "courseradownloader": "coursera-dl",
+ "cow": "cow-framework",
+ "creole": "python-creole",
+ "creoleparser": "Creoleparser",
+ "crispy_forms": "django-crispy-forms",
+ "crontab": "python-crontab",
+ "ctff": "tff",
+ "cups": "pycups",
+ "curator": "elasticsearch-curator",
+ "curl": "pycurl",
+ "daemon": "python-daemon",
+ "dare": "DARE",
+ "dateutil": "python-dateutil",
+ "dawg": "DAWG",
+ "debian": "python-debian",
+ "decouple": "python-decouple",
+ "demo": "webunit",
+ "pysynth_samp": "PySynth",
+ "deployer": "juju-deployer",
+ "depot": "filedepot",
+ "devtools": "tg.devtools",
+ "dgis": "2gis",
+ "dhtmlparser": "pyDHTMLParser",
+ "digitalocean": "python-digitalocean",
+ "discord": "discord.py",
+ "distribute_setup": "ez-setup",
+ "distutils2": "Distutils2",
+ "django": "Django",
+ "django_hstore": "amitu-hstore",
+ "djangobower": "django-bower",
+ "djcelery": "django-celery",
+ "djkombu": "django-kombu",
+ "djorm_pgarray": "djorm-ext-pgarray",
+ "dns": "dnspython",
+ "docgen": "ansible-docgenerator",
+ "docker": "docker-py",
+ "dogpile": "dogpile.core",
+ "dogshell": "dogapi",
+ "dot_parser": "pydot3k",
+ "dotenv": "python-dotenv",
+ "dpkt": "dpkt-fix",
+ "ldif": "python-ldap",
+ "durationfield": "django-durationfield",
+ "dzclient": "datazilla",
+ "easybuild": "easybuild-framework",
+ "editor": "python-editor",
+ "elasticluster": "azure-elasticluster-current",
+ "elftools": "pyelftools",
+ "elixir": "Elixir",
+ "emlib": "empy",
+ "enchant": "pyenchant",
+ "encutils": "cssutils",
+ "engineio": "python-engineio",
+ "enum": "enum34",
+ "ephem": "pyephem",
+ "errorreporter": "abl.errorreporter",
+ "esplot": "beaker-es-plot",
+ "example": "adrest",
+ "examples": "tweepy",
+ "ez_setup": "pycassa",
+ "fabric": "Fabric",
+ "faker": "Faker",
+ "fedora": "python-fedora",
+ "fias": "ailove-django-fias",
+ "fiftyone_degrees": "51degrees-mobile-detector",
+ "five": "five.pt",
+ "flasher": "android-flasher",
+ "flask": "Flask",
+ "flask_frozen": "Frozen-Flask",
+ "flask_redis": "Flask-And-Redis",
+ "flaskext": "Flask-Bcrypt",
+ "flvscreen": "vnc2flv",
+ "followit": "django-followit",
+ "forge": "pyforge",
+ "formencode": "FormEncode",
+ "formtools": "django-formtools",
+ "fourch": "4ch",
+ "franz": "allegrordf",
+ "freetype": "freetype-py",
+ "frontmatter": "python-frontmatter",
+ "ftpcloudfs": "ftp-cloudfs",
+ "funtests": "librabbitmq",
+ "fuse": "fusepy",
+ "fuzzy": "Fuzzy",
+ "gabbi": "tiddlyweb",
+ "gen_3dwallet": "3d-wallet-generator",
+ "gendimen": "android-gendimen",
+ "genshi": "Genshi",
+ "quadtree": "python-geohash",
+ "geonode": "GeoNode",
+ "geoserver": "gsconfig",
+ "geraldo": "Geraldo",
+ "getenv": "django-getenv",
+ "geventwebsocket": "gevent-websocket",
+ "gflags": "python-gflags",
+ "git": "GitPython",
+ "github": "PyGithub",
+ "github3": "github3.py",
+ "gitpy": "git-py",
+ "globusonline": "globusonline-transfer-api-client",
+ "google": "protobuf",
+ "grace-dizmo": "grace-dizmo",
+ "grammar": "anovelmous-grammar",
+ "grapheneapi": "graphenelib",
+ "greplin": "scales",
+ "grokcore": "grokcore.component",
+ "gslib": "gsutil",
+ "hamcrest": "PyHamcrest",
+ "harpy": "HARPy",
+ "hawk": "PyHawk-with-a-single-extra-commit",
+ "haystack": "django-haystack",
+ "hgext": "mercurial",
+ "hggit": "hg-git",
+ "hglib": "python-hglib",
+ "sx": "pisa",
+ "hola": "amarokHola",
+ "hoover": "Hoover",
+ "hostlist": "python-hostlist",
+ "htmloutput": "nosehtmloutput",
+ "hvad": "django-hvad",
+ "hydra": "hydra-core",
+ "i99fix": "199Fix",
+ "igraph": "python-igraph",
+ "imdb": "IMDbPY",
+ "impala": "impyla",
+ "inmemorystorage": "ambition-inmemorystorage",
+ "ipaddress": "backport-ipaddress",
+ "jaraco": "jaraco.util",
+ "jinja2": "Jinja2",
+ "jiracli": "jira-cli",
+ "johnny": "johnny-cache",
+ "jpypex": "JPype1",
+ "jsonfield": "django-jsonfield",
+ "jstools": "aino-jstools",
+ "jupyterpip": "jupyter-pip",
+ "jwt": "PyJWT",
+ "kazoo": "asana-kazoo",
+ "kernprof": "line-profiler",
+ "keyczar": "python-keyczar",
+ "keyedcache": "django-keyedcache",
+ "keystoneclient": "python-keystoneclient",
+ "kickstarter": "kickstart",
+ "krbv": "krbV",
+ "kss": "kss.core",
+ "kuyruk": "Kuyruk",
+ "langconv": "AdvancedLangConv",
+ "lava": "lava-utils-interface",
+ "lazr": "lazr.uri",
+ "ldaplib": "adpasswd",
+ "lib2or3": "2or3",
+ "lib3to2": "3to2",
+ "libaito": "Aito",
+ "libbe": "bugs-everywhere",
+ "libbucket": "bucket",
+ "libcloud": "apache-libcloud",
+ "winreg": "future",
+ "libgenerateDS": "generateDS",
+ "libmproxy": "mitmproxy",
+ "libsvm": "7lk-ocr-deploy",
+ "lisa": "lisa-server",
+ "loadingandsaving": "aspose-words-java-for-python",
+ "locust": "locustio",
+ "logbook": "Logbook",
+ "logentries": "buildbot-status-logentries",
+ "logilab": "logilab-mtconverter",
+ "magic": "python-magic",
+ "mako": "Mako",
+ "manifestparser": "ManifestDestiny",
+ "marionette": "marionette-client",
+ "markdown": "Markdown",
+ "marks": "pytest-marks",
+ "markupsafe": "MarkupSafe",
+ "mavnative": "pymavlink",
+ "memcache": "python-memcached",
+ "metacomm": "AllPairs",
+ "metaphone": "Metafone",
+ "metlog": "metlog-py",
+ "mezzanine": "Mezzanine",
+ "migrate": "sqlalchemy-migrate",
+ "mimeparse": "python-mimeparse",
+ "minitage": "minitage.recipe.common",
+ "missingdrawables": "android-missingdrawables",
+ "mkrst_themes": "2lazy2rest",
+ "mockredis": "mockredispy",
+ "modargs": "python-modargs",
+ "model_utils": "django-model-utils",
+ "models": "asposestorage",
+ "moksha": "moksha.wsgi",
+ "moneyed": "py-moneyed",
+ "mongoalchemy": "MongoAlchemy",
+ "monthdelta": "MonthDelta",
+ "mopidy": "Mopidy",
+ "mopytools": "MoPyTools",
+ "mptt": "django-mptt",
+ "mpv": "python-mpv",
+ "mrbob": "mr.bob",
+ "msgpack": "msgpack-python",
+ "mutations": "aino-mutations",
+ "mws": "amazon-mws",
+ "mysql": "mysql-connector-repackaged",
+ "native_tags": "django-native-tags",
+ "ndg": "ndg-httpsclient",
+ "nereid": "trytond-nereid",
+ "nested": "baojinhuan",
+ "nester": "bssm-pythonSig",
+ "novaclient": "python-novaclient",
+ "oauth2_provider": "alauda-django-oauth",
+ "oauth2client": "oauth2client",
+ "odf": "odfpy",
+ "ometa": "Parsley",
+ "openid": "python-openid",
+ "opensearchsdk": "ali-opensearch",
+ "oslo_i18n": "oslo.i18n",
+ "oslo_serialization": "oslo.serialization",
+ "oslo_utils": "oslo.utils",
+ "oss": "aliyunoss",
+ "output": "cashew",
+ "owslib": "OWSLib",
+ "rackdiag": "nwdiag",
+ "paho": "paho-mqtt",
+ "paintstore": "django-paintstore",
+ "parler": "django-parler",
+ "paste": "PasteScript",
+ "path": "path.py",
+ "patricia": "patricia-trie",
+ "paver": "Paver",
+ "peak": "ProxyTypes",
+ "picasso": "anderson.picasso",
+ "picklefield": "django-picklefield",
+ "pivotal": "pivotal-py",
+ "pwiz": "peewee",
+ "plivoxml": "plivo",
+ "plone": "plone.z3cform",
+ "plonetheme": "plonetheme.barceloneta",
+ "png": "pypng",
+ "polymorphic": "django-polymorphic",
+ "postmark": "python-postmark",
+ "powerprompt": "bash-powerprompt",
+ "prefetch": "django-prefetch",
+ "printList": "AndrewList",
+ "progressbar": "progressbar33",
+ "provider": "django-oauth2-provider",
+ "puresasl": "pure-sasl",
+ "py7zlib": "pylzma",
+ "pyAMI": "pyAMI-core",
+ "pyarsespyder": "arsespyder",
+ "pyasdf": "asdf",
+ "pyaspell": "aspell-python-ctypes",
+ "pybb": "pybbm",
+ "pybloomfilter": "pybloomfiltermmap",
+ "pyccuracy": "Pyccuracy",
+ "pyck": "PyCK",
+ "pycrfsuite": "python-crfsuite",
+ "pydispatch": "PyDispatcher",
+ "pygeolib": "pygeocoder",
+ "pygments": "Pygments",
+ "pygraph": "python-graph-core",
+ "pyjon": "pyjon.utils",
+ "pyjsonrpc": "python-jsonrpc",
+ "pykka": "Pykka",
+ "pylogo": "PyLogo",
+ "pylons": "adhocracy-Pylons",
+ "pymagic": "libmagic",
+ "pymycraawler": "Amalwebcrawler",
+ "pynma": "AbakaffeNotifier",
+ "pyphen": "Pyphen",
+ "pyrimaa": "AEI",
+ "pysqlite2": "pysqlite",
+ "pythongettext": "python-gettext",
+ "pythonjsonlogger": "python-json-logger",
+ "pyutilib": "PyUtilib",
+ "pyximport": "Cython",
+ "qs": "qserve",
+ "quickapi": "django-quickapi",
+ "quickunit": "nose-quickunit",
+ "radical": "radical.utils",
+ "readability": "readability-lxml",
+ "readline": "gnureadline",
+ "recaptcha_works": "django-recaptcha-works",
+ "relstorage": "RelStorage",
+ "reportapi": "django-reportapi",
+ "requests": "Requests",
+ "requirements": "requirements-parser",
+ "rest_framework": "djangorestframework",
+ "restclient": "py-restclient",
+ "retrial": "async-retrial",
+ "reversion": "django-reversion",
+ "rhaptos2": "rhaptos2.common",
+ "robot": "robotframework",
+ "robots": "django-robots",
+ "rosdep2": "rosdep",
+ "rsbackends": "RSFile",
+ "ruamel": "ruamel.base",
+ "xmlenc": "pysaml2",
+ "saga": "saga-python",
+ "samtranslator": "aws-sam-translator",
+ "sassutils": "libsass",
+ "sayhi": "alex-sayhi",
+ "scalrtools": "scalr",
+ "scikits": "scikits.talkbox",
+ "scratch": "scratchpy",
+ "scss": "pyScss",
+ "sdict": "dict.sorted",
+ "sdk_updater": "android-sdk-updater",
+ "sekizai": "django-sekizai",
+ "sendfile": "pysendfile",
+ "serial": "pyserial",
+ "setuputils": "astor",
+ "shapefile": "pyshp",
+ "shapely": "Shapely",
+ "sika": "ahonya-sika",
+ "singleton": "pysingleton",
+ "skbio": "scikit-bio",
+ "sklearn": "scikit-learn",
+ "slack": "slackclient",
+ "slugify": "unicode-slugify",
+ "smarkets": "smk-python-sdk",
+ "snappy": "ctypes-snappy",
+ "socketio": "gevent-socketio",
+ "sockjs": "sockjs-tornado",
+ "socks": "SocksiPy-branch",
+ "solr": "solrpy",
+ "solution": "Solution",
+ "sorl": "sorl-thumbnail",
+ "south": "South",
+ "sphinx": "Sphinx",
+ "sphinx_pypi_upload": "ATD-document",
+ "sphinxcontrib": "sphinxcontrib-programoutput",
+ "sqlalchemy": "SQLAlchemy",
+ "src": "auto-mix-prep",
+ "stats_toolkit": "bw-stats-toolkit",
+ "statsd": "dogstatsd-python",
+ "stdnum": "python-stdnum",
+ "stoneagehtml": "StoneageHTML",
+ "storages": "django-storages",
+ "stubout": "mox",
+ "suds": "suds-jurko",
+ "swiftclient": "python-swiftclient",
+ "test": "pytabix",
+ "taggit": "django-taggit",
+ "tastypie": "django-tastypie",
+ "teamcity": "teamcity-messages",
+ "telebot": "pyTelegramBotAPI",
+ "tempita": "Tempita",
+ "tenjin": "Tenjin",
+ "termstyle": "python-termstyle",
+ "thclient": "treeherder-client",
+ "threaded_multihost": "django-threaded-multihost",
+ "threecolor": "3color-Press",
+ "tidylib": "pytidylib",
+ "tlw": "3lwg",
+ "toredis": "toredis-fork",
+ "tornadoredis": "tornado-redis",
+ "tower_cli": "ansible-tower-cli",
+ "tracopt": "Trac",
+ "translation_helper": "android-localization-helper",
+ "treebeard": "django-treebeard",
+ "trytond": "trytond-stock",
+ "tsuru": "tsuru-circus",
+ "tvrage": "python-tvrage",
+ "tw2": "tw2.sqla",
+ "twisted": "Twisted",
+ "twitter": "python-twitter",
+ "txclib": "transifex-client",
+ "u115": "115wangpan",
+ "unidecode": "Unidecode",
+ "universe": "ansible-universe",
+ "usb": "pyusb",
+ "useless": "useless.pipes",
+ "userpass": "auth-userpass",
+ "utilities": "automakesetup.py",
+ "utkik": "aino-utkik",
+ "uwsgidecorators": "uWSGI",
+ "valentine": "ab",
+ "validate": "configobj",
+ "version": "chartio",
+ "virtualenvapi": "ar-virtualenv-api",
+ "vyatta": "brocade-plugins",
+ "webob": "WebOb",
+ "websocket": "websocket-client",
+ "webtest": "WebTest",
+ "werkzeug": "Werkzeug",
+ "wheezy": "wheezy.http",
+ "wikklytext": "tiddlywebwiki",
+ "winrm": "pywinrm",
+ "workflow": "Alfred-Workflow",
+ "wsmeext": "WSME",
+ "wtforms": "WTForms",
+ "wtfpeewee": "wtf-peewee",
+ "xdg": "pyxdg",
+ "xdist": "pytest-xdist",
+ "xmpp": "xmpppy",
+ "xstatic": "XStatic-jquery-ui",
+ "yaml": "PyYAML",
+ "z3c": "z3c.zcmlhook",
+ "zmq": "pyzmq",
+ "zopyx": "zopyx.textindexng3",
+ }
diff --git a/marimo/_runtime/packages/module_registry.py b/marimo/_runtime/packages/module_registry.py
new file mode 100644
index 0000000000..1eb87c7a1c
--- /dev/null
+++ b/marimo/_runtime/packages/module_registry.py
@@ -0,0 +1,44 @@
+# Copyright 2024 Marimo. All rights reserved.
+from __future__ import annotations
+
+import importlib.util
+
+from marimo._ast.cell import CellId_t
+from marimo._runtime.dataflow import DirectedGraph
+
+
+class ModuleRegistry:
+ def __init__(
+ self, graph: DirectedGraph, excluded_modules: set[str] | None = None
+ ) -> None:
+ self.graph = graph
+ # modules that do not have corresponding packages on package index
+ self.excluded_modules = (
+ excluded_modules if excluded_modules is not None else set()
+ )
+
+ def defining_cell(self, module_name: str) -> CellId_t | None:
+ """Get the cell id of the cell importing module_name"""
+ for cell_id, cell in self.graph.cells.items():
+ if cell.module_to_variable(module_name) is not None:
+ return cell_id
+ return None
+
+ def modules(self) -> set[str]:
+ """Modules imported by cells."""
+ return set(
+ mod
+ for cell in self.graph.cells.values()
+ for mod in cell.imported_modules
+ )
+
+ def missing_modules(self) -> set[str]:
+ """Modules that will fail to import."""
+ return (
+ set(
+ mod
+ for mod in self.modules()
+ if importlib.util.find_spec(mod) is None
+ )
+ - self.excluded_modules
+ )
diff --git a/marimo/_runtime/packages/package_manager.py b/marimo/_runtime/packages/package_manager.py
new file mode 100644
index 0000000000..86967abe02
--- /dev/null
+++ b/marimo/_runtime/packages/package_manager.py
@@ -0,0 +1,26 @@
+# Copyright 2024 Marimo. All rights reserved.
+from __future__ import annotations
+
+import abc
+
+
+class PackageManager(abc.ABC):
+ """Interface for a package manager that can install packages."""
+
+ @abc.abstractmethod
+ def module_to_package(self, module_name: str) -> str:
+ """Canonicalizes a module name to a package name."""
+ ...
+
+ @abc.abstractmethod
+ def package_to_module(self, package_name: str) -> str:
+ """Canonicalizes a package name to a module name."""
+ ...
+
+ @abc.abstractmethod
+ async def install(self, package: str) -> bool:
+ """Attempt to install a package that makes this module available.
+
+ Returns True if installation succeeded, else False.
+ """
+ ...
diff --git a/marimo/_runtime/packages/pypi_package_manager.py b/marimo/_runtime/packages/pypi_package_manager.py
new file mode 100644
index 0000000000..042a69f712
--- /dev/null
+++ b/marimo/_runtime/packages/pypi_package_manager.py
@@ -0,0 +1,70 @@
+# Copyright 2024 Marimo. All rights reserved.
+from __future__ import annotations
+
+import subprocess
+
+from marimo._runtime.packages.module_name_to_pypi_name import (
+ module_name_to_pypi_name,
+)
+from marimo._runtime.packages.package_manager import PackageManager
+from marimo._utils.platform import is_pyodide
+
+
+class PypiPackageManager(PackageManager):
+ """Implements installation for both pip and micropip.
+
+ Can fork into two different classes if needed.
+ """
+
+ def __init__(self) -> None:
+ self._module_name_to_pypi_name: dict[str, str] | None = None
+ self._pypi_name_to_module_name: dict[str, str] | None = None
+
+ def _initialize_mappings(self) -> None:
+ if self._module_name_to_pypi_name is None:
+ self._module_name_to_pypi_name = module_name_to_pypi_name()
+
+ if self._pypi_name_to_module_name is None:
+ self._pypi_name_to_module_name = {
+ v: k for k, v in self._module_name_to_pypi_name.items()
+ }
+
+ def module_to_package(self, module_name: str) -> str:
+ """Canonicalizes a module name to a package name on PyPI."""
+ if self._module_name_to_pypi_name is None:
+ self._initialize_mappings()
+ assert self._module_name_to_pypi_name is not None
+
+ if module_name in self._module_name_to_pypi_name:
+ return self._module_name_to_pypi_name[module_name]
+ else:
+ return module_name.replace("_", "-")
+
+ def package_to_module(self, package_name: str) -> str:
+ """Canonicalizes a package name to a module name."""
+ if self._pypi_name_to_module_name is None:
+ self._initialize_mappings()
+ assert self._pypi_name_to_module_name is not None
+
+ return (
+ self._pypi_name_to_module_name[package_name]
+ if package_name in self._pypi_name_to_module_name
+ else package_name.replace("-", "_")
+ )
+
+
+class PipPackageManager(PypiPackageManager):
+ async def install(self, package: str) -> bool:
+ return subprocess.run(["pip", "install", package]).returncode == 0
+
+
+class MicropipPackageManager(PypiPackageManager):
+ async def install(self, package: str) -> bool:
+ assert is_pyodide()
+ import micropip # type: ignore
+
+ try:
+ await micropip.install(package)
+ return True
+ except ValueError:
+ return False
diff --git a/marimo/_runtime/packages/utils.py b/marimo/_runtime/packages/utils.py
new file mode 100644
index 0000000000..cc62d58eae
--- /dev/null
+++ b/marimo/_runtime/packages/utils.py
@@ -0,0 +1,25 @@
+# Copyright 2024 Marimo. All rights reserved.
+import os
+import sys
+
+from marimo._utils.platform import is_pyodide
+
+
+def in_virtual_environment() -> bool:
+ """Returns True if a venv/virtualenv is activated"""
+ # https://stackoverflow.com/questions/1871549/how-to-determine-if-python-is-running-inside-a-virtualenv/40099080#40099080 # noqa: E501
+ base_prefix = (
+ getattr(sys, "base_prefix", None)
+ or getattr(sys, "real_prefix", None)
+ or sys.prefix
+ )
+ return sys.prefix != base_prefix
+
+
+def in_conda_env() -> bool:
+ return "CONDA_DEFAULT_ENV" in os.environ
+
+
+def is_python_isolated() -> bool:
+ """Returns True if not using system Python"""
+ return in_virtual_environment() or in_conda_env() or is_pyodide()
diff --git a/marimo/_runtime/requests.py b/marimo/_runtime/requests.py
index 98904adb7e..a70068c02a 100644
--- a/marimo/_runtime/requests.py
+++ b/marimo/_runtime/requests.py
@@ -72,6 +72,12 @@ class CompletionRequest:
cell_id: CellId_t
+@dataclass
+class InstallMissingPackagesRequest:
+ # TODO: package manager (pip/conda/...), index URL (index/channel/...)
+ manager: str
+
+
ControlRequest = Union[
ExecuteMultipleRequest,
CreationRequest,
@@ -80,4 +86,5 @@ ControlRequest = Union[
SetCellConfigRequest,
SetUIElementValueRequest,
StopRequest,
+ InstallMissingPackagesRequest,
]
diff --git a/marimo/_runtime/runtime.py b/marimo/_runtime/runtime.py
index c7156bf7e4..be8d03fcee 100644
--- a/marimo/_runtime/runtime.py
+++ b/marimo/_runtime/runtime.py
@@ -35,6 +35,9 @@ from marimo._messaging.ops import (
CompletedRun,
FunctionCallResult,
HumanReadableStatus,
+ InstallingPackageAlert,
+ MissingPackageAlert,
+ PackageStatusType,
RemoveUIElements,
VariableDeclaration,
Variables,
@@ -75,6 +78,10 @@ from marimo._runtime.context import (
)
from marimo._runtime.control_flow import MarimoInterrupt, MarimoStopError
from marimo._runtime.input_override import input_override
+from marimo._runtime.packages.module_registry import ModuleRegistry
+from marimo._runtime.packages.package_manager import PackageManager
+from marimo._runtime.packages.pypi_package_manager import PipPackageManager
+from marimo._runtime.packages.utils import is_python_isolated
from marimo._runtime.redirect_streams import redirect_streams
from marimo._runtime.requests import (
AppMetadata,
@@ -85,6 +92,7 @@ from marimo._runtime.requests import (
ExecuteMultipleRequest,
ExecutionRequest,
FunctionCallRequest,
+ InstallMissingPackagesRequest,
SetCellConfigRequest,
SetUIElementValueRequest,
StopRequest,
@@ -201,6 +209,7 @@ class Kernel:
stdin: Stdin | None,
input_override: Callable[[Any], str] = input_override,
debugger_override: marimo_pdb.MarimoPdb | None = None,
+ package_manager: PackageManager | None = None,
) -> None:
self.app_metadata = app_metadata
self.stream = stream
@@ -221,6 +230,10 @@ class Kernel:
cell_id: CellMetadata(config=config)
for cell_id, config in cell_configs.items()
}
+ self.module_registry = ModuleRegistry(
+ self.graph, excluded_modules=set()
+ )
+ self.package_manager = package_manager
self.execution_context: Optional[ExecutionContext] = None
# initializers to override construction of ui elements
@@ -384,10 +397,31 @@ class Kernel:
`exclude_defs`, and instructs the frontend to invalidate its UI
elements.
"""
+ missing_modules_before_deletion = (
+ self.module_registry.missing_modules()
+ )
defs_to_delete = self.graph.cells[cell_id].defs
self._delete_names(
defs_to_delete, exclude_defs if exclude_defs is not None else set()
)
+
+ missing_modules_after_deletion = self.module_registry.missing_modules()
+ if (
+ self.package_manager is not None
+ and missing_modules_after_deletion
+ != missing_modules_before_deletion
+ ):
+ # Deleting a cell can make the set of missing packages smaller
+ MissingPackageAlert(
+ packages=list(
+ sorted(
+ self.package_manager.module_to_package(mod)
+ for mod in missing_modules_after_deletion
+ )
+ ),
+ isolated=is_python_isolated(),
+ ).broadcast()
+
get_context().cell_lifecycle_registry.dispose(
cell_id, deletion=deletion
)
@@ -830,6 +864,23 @@ class Kernel:
status="idle",
)
+ if (
+ any(
+ isinstance(e, ModuleNotFoundError)
+ for e in runner.exceptions.values()
+ )
+ and self.package_manager is not None
+ ):
+ missing_packages = [
+ self.package_manager.module_to_package(mod)
+ for mod in self.module_registry.missing_modules()
+ ]
+ if missing_packages:
+ MissingPackageAlert(
+ packages=list(sorted(missing_packages)),
+ isolated=is_python_isolated(),
+ ).broadcast()
+
cells_with_stale_state = runner.resolve_state_updates(
self.state_updates, self.errors
)
@@ -1112,8 +1163,52 @@ class Kernel:
await self.run(request.execution_requests)
self.reset_ui_initializers()
+ async def install_missing_packages(self) -> None:
+ """Attempts to install packages for modules that cannot be imported
+
+ Runs cells affected by successful installation.
+ """
+ assert self.package_manager is not None
+ # Package manager operates on module names
+ missing_modules = list(sorted(self.module_registry.missing_modules()))
+
+ # Frontend shows package names, not module names
+ package_statuses: PackageStatusType = {
+ self.package_manager.module_to_package(mod): "queued"
+ for mod in missing_modules
+ }
+ InstallingPackageAlert(packages=package_statuses).broadcast()
+
+ for mod in missing_modules:
+ pkg = self.package_manager.module_to_package(mod)
+ package_statuses[pkg] = "installing"
+ InstallingPackageAlert(packages=package_statuses).broadcast()
+ if await self.package_manager.install(pkg):
+ package_statuses[pkg] = "installed"
+ InstallingPackageAlert(packages=package_statuses).broadcast()
+ else:
+ package_statuses[pkg] = "failed"
+ self.module_registry.excluded_modules.add(mod)
+ InstallingPackageAlert(packages=package_statuses).broadcast()
+
+ installed_modules = [
+ self.package_manager.package_to_module(pkg)
+ for pkg in package_statuses
+ if package_statuses[pkg] == "installed"
+ ]
+ cells_to_run = set(
+ cid
+ for module in installed_modules
+ if (cid := self.module_registry.defining_cell(module)) is not None
+ )
+ if cells_to_run:
+ await self._run_cells(
+ dataflow.transitive_closure(self.graph, cells_to_run)
+ )
+
async def handle_message(self, request: ControlRequest) -> None:
"""Handle a message from the client.
+
The message is dispatched to the appropriate method based on its type.
"""
if isinstance(request, CreationRequest):
@@ -1137,6 +1232,9 @@ class Kernel:
CompletedRun().broadcast()
elif isinstance(request, DeleteRequest):
await self.delete(request)
+ elif isinstance(request, InstallMissingPackagesRequest):
+ await self.install_missing_packages()
+ CompletedRun().broadcast()
elif isinstance(request, StopRequest):
return None
else:
@@ -1196,6 +1294,7 @@ def launch_kernel(
stdin=stdin,
input_override=input_override,
debugger_override=debugger,
+ package_manager=PipPackageManager(),
)
initialize_context(
kernel=kernel,
diff --git a/marimo/_server/api/endpoints/editing.py b/marimo/_server/api/endpoints/editing.py
index ba1f1185c6..294d6ed50d 100644
--- a/marimo/_server/api/endpoints/editing.py
+++ b/marimo/_server/api/endpoints/editing.py
@@ -7,6 +7,7 @@ from starlette.requests import Request
from marimo._runtime.requests import (
CompletionRequest,
DeleteRequest,
+ InstallMissingPackagesRequest,
SetCellConfigRequest,
)
from marimo._server.api.deps import AppState
@@ -77,3 +78,14 @@ async def stdin(request: Request) -> BaseResponse:
app_state.require_current_session().put_input(body.text)
return SuccessResponse()
+
+
+# TODO(akshayka): allow in run mode when in pyodide
[email protected]("/install_missing_packages")
+@requires("edit")
+async def install_missing_packages(request: Request) -> BaseResponse:
+ """Install missing packages"""
+ app_state = AppState(request)
+ body = await parse_request(request, cls=InstallMissingPackagesRequest)
+ app_state.require_current_session().put_control_request(body)
+ return SuccessResponse()
diff --git a/marimo/_tutorials/intro.py b/marimo/_tutorials/intro.py
index f47002c868..9f1f8daedc 100644
--- a/marimo/_tutorials/intro.py
+++ b/marimo/_tutorials/intro.py
@@ -1,10 +1,17 @@
# Copyright 2024 Marimo. All rights reserved.
+
import marimo
-__generated_with = "0.1.88"
+__generated_with = "0.3.2"
app = marimo.App()
+def __():
+ import foo
+ return foo,
+
+
@app.cell
def __():
import marimo as mo
diff --git a/pyproject.toml b/pyproject.toml
index 88e142932b..34b29d4457 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -224,5 +224,6 @@ wheres = "wheres"
[tool.typos.files]
extend-exclude = [
- "MultiSelectPlugin.test.ts"
+ "MultiSelectPlugin.test.ts",
+ "module_name_to_pypi_name.py"
]
diff --git a/tests/_runtime/packages/test_module_registry.py b/tests/_runtime/packages/test_module_registry.py
new file mode 100644
index 0000000000..ca33f75071
--- /dev/null
+++ b/tests/_runtime/packages/test_module_registry.py
@@ -0,0 +1,35 @@
+from functools import partial
+
+from marimo._ast import compiler
+from marimo._runtime.dataflow import DirectedGraph
+from marimo._runtime.packages.module_registry import ModuleRegistry
+
+parse_cell = partial(compiler.compile_cell, cell_id="0")
+
+
+def test_defining_cell() -> None:
+ mgr = ModuleRegistry(graph := DirectedGraph())
+ mpl = parse_cell("import matplotlib")
+ np = parse_cell("import numpy")
+ graph.register_cell("0", mpl)
+ graph.register_cell("1", np)
+ assert mgr.defining_cell("matplotlib") == "0"
+ assert mgr.defining_cell("numpy") == "1"
+
+
+def test_defining_cell_dotted() -> None:
+ mgr = ModuleRegistry(graph := DirectedGraph())
+ mpl = parse_cell("import matplotlib.pyplot as plt")
+ graph.register_cell("0", mpl)
+ assert mgr.defining_cell("matplotlib") == "0"
+ assert mgr.defining_cell("pyplot") is None
+ assert mgr.defining_cell("plt") is None
+
+
+def test_missing_modules() -> None:
+ mgr = ModuleRegistry(graph := DirectedGraph())
+ graph.register_cell("0", parse_cell("import does.nt.exist as foo"))
+ graph.register_cell(
+ "1", parse_cell("import time; import super_fake_package")
+ )
+ assert mgr.missing_modules() == set(["does", "super_fake_package"])
diff --git a/tests/_runtime/packages/test_package_utils.py b/tests/_runtime/packages/test_package_utils.py
new file mode 100644
index 0000000000..a031d08e78
--- /dev/null
+++ b/tests/_runtime/packages/test_package_utils.py
@@ -0,0 +1,13 @@
+import sys
+
+import pytest
+
+from marimo._runtime.packages.utils import is_python_isolated
+
+
+# TODO(akshayka): virtualenv not activating on windows CI
[email protected](sys.platform == "win32", reason="Failing on Windows CI")
+def test_is_python_isolated() -> None:
+ # tests should always be run in an isolated (non-system) environment;
+ # we only run them in a virtualenv, venv, or conda env ...
+ assert is_python_isolated()
diff --git a/tests/_runtime/packages/test_pypi_package_manager.py b/tests/_runtime/packages/test_pypi_package_manager.py
new file mode 100644
index 0000000000..9945edc65b
--- /dev/null
+++ b/tests/_runtime/packages/test_pypi_package_manager.py
@@ -0,0 +1,26 @@
+from functools import partial
+
+from marimo._ast import compiler
+from marimo._runtime.packages.pypi_package_manager import PipPackageManager
+
+parse_cell = partial(compiler.compile_cell, cell_id="0")
+
+
+def test_module_to_package() -> None:
+ mgr = PipPackageManager()
+ assert mgr.module_to_package("marimo") == "marimo"
+ assert mgr.module_to_package("123_456_789") == "123-456-789"
+ assert mgr.module_to_package("sklearn") == "scikit-learn"
+
+
+def test_package_to_module() -> None:
+ mgr = PipPackageManager()
+ assert mgr.package_to_module("marimo") == "marimo"
+ assert mgr.package_to_module("123-456-789") == "123_456_789"
+ assert mgr.package_to_module("scikit-learn") == "sklearn"
+
+
+async def test_failed_install_returns_false() -> None:
+ mgr = PipPackageManager()
+ # almost surely does not exist
+ assert not await mgr.install("asdfasdfasdfasdfqwerty")
diff --git a/tests/_server/api/endpoints/test_editing.py b/tests/_server/api/endpoints/test_editing.py
index 8275c70256..7f2b81fff3 100644
--- a/tests/_server/api/endpoints/test_editing.py
+++ b/tests/_server/api/endpoints/test_editing.py
@@ -61,6 +61,20 @@ def test_format_cell(client: TestClient) -> None:
assert formatted_codes["cell-123"] == "def foo():\n return 1"
+@with_session(SESSION_ID)
+def test_install_missing_packages(client: TestClient) -> None:
+ response = client.post(
+ "/api/kernel/install_missing_packages",
+ headers=HEADERS,
+ json={
+ "manager": "pip",
+ },
+ )
+ assert response.status_code == 200, response.text
+ assert response.headers["content-type"] == "application/json"
+ assert "success" in response.json()
+
+
@with_session(SESSION_ID)
def test_set_cell_config(client: TestClient) -> None:
response = client.post(