🐍 Python Manager
A comprehensive TypeScript library for managing Python environments, installations, and package dependencies. This library provides a unified interface for handling Python version management, virtual environments, package installation, and script execution.
Features
🔧 Installation
npm install python-manager
yarn add python-manager
bun add python-manager
📄 Documentation
Check The Documentation Website
🖥️🛠️ Usage
Python Installation and Management
import { PythonInstaller } from "python-manager";
const installer = new PythonInstaller();
const pythonPath = await installer.ensurePythonInstalled(
"3.9.1",
"test/.pyenv"
);
Python Version Management
import { PythonVersionManager } from "python-manager";
const versionManager = new PythonVersionManager();
await versionManager.installVersion("3.9.1");
await versionManager.setLocalVersion("3.9.1");
const versions = await versionManager.listInstalledVersions();
Virtual Environment Management
import { VirtualEnvManager } from "python-manager";
const venvManager = new VirtualEnvManager();
await venvManager.createVenv("./my-venv");
const exists = await venvManager.existsVenv("./my-venv");
await venvManager.deleteVenv("./my-venv");
Package Management
import { PipManager } from "python-manager";
const pipManager = new PipManager();
await pipManager.install("requests");
await pipManager.installMultiple(["numpy", "pandas", "matplotlib"]);
await pipManager.installRequirementsFile("./requirements.txt");
const packages = await pipManager.listInstalledPackages();
Python Execution
import { PythonExecutor } from "python-manager";
const executor = new PythonExecutor();
const result = await executor.runScript(
"./script.py",
["--arg1", "value1"],
"python",
true
);
const codeResult = await executor.runCode(
'print("Hello, World!")',
"python",
true
);
Requirements
- Node.js 20.x or higher
- Administrative rights (for some installation operations)
Platform Support
- Windows: Full support with pyenv-win
- Linux: Full support with pyenv (Soon)
- macOS: Full support with pyenv (Soon)
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Support
If you encounter any issues or have questions, please file an issue on the GitHub repository.