The path where the virtual environment will be created.
The Python executable to use (defaults to "python").
Delete a virtual environment by removing its directory recursively.
The path to the virtual environment.
Check if a virtual environment exists at the specified path.
The path to the virtual environment.
A promise that resolves to true
if the virtual environment exists, and false
otherwise.
This function uses the fsPromises.access
method to check if the virtual environment directory exists.
If the directory exists, the function resolves to true
; otherwise, it resolves to false
.
const venvManager = new VirtualEnvManager();
const venvPath = "path/to/virtual/environment";
try {
const venvExists = await venvManager.existsVenv(venvPath);
if (venvExists) {
console.log("Virtual environment exists.");
} else {
console.log("Virtual environment does not exist.");
}
} catch (error) {
console.error("Error checking virtual environment:", error);
}
Create a Python virtual environment.