denosaurs / denosaurs/python.mod.land
suggestion: Auto-install Python modules with pip if module is not installed
- Vorherrschende Sprache
- TypeScript
- Sterne
- 11
- Forks
- 1
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
Great work on this project! 🎉
I think it would be a good idea to add code to try and install a Python module if it's not already installed.
I wrote a very simple proof-of-concept for one of my projects here:
https://github.com/tjosepo/deno_numpy/blob/main/src/shared/numpy.ts
```ts
import { python, PythonError } from "../../deps.ts";
let numpy: any;
try {
numpy = python.import("numpy");
} catch (error: unknown) {
if (!(error instanceof PythonError)) throw error;
if (error.message !== "No module named 'numpy'") throw error;
const p = Deno.run({ cmd: "pip install numpy".split(" ") });
await p.status();
numpy = python.import("numpy");
}
export default numpy;
```
This approach isn't perfect as it assumes the user has pip installed, but I feel like it would be a good improvement for most users, and it can be further iterated upon in the future.
Beitragsleitfaden
Für dieses Repository ist kein Beitragsleitfaden indexiert
Rechercherichtung
Es ist keine Repository-Datei oder kein Test angegeben. Beginne damit, den Modulimport und die Behandlung von PythonError rund um python.import zu lesen, und vergleiche anschließend das verlinkte src/shared/numpy.ts Proof of Concept und dessen Deno.run-Flow für pip install. Done sollte eine abgestimmte Installationsrichtlinie, ein Fehlerverhalten und Tests für fehlende und erfolgreich installierte Module umfassen.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- python, typescript
- Bereich
- tooling
- Issue-Typ
- Feature
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 25/100