# withVirtualEnvironment

- Module: [Aspire.Hosting.Python](/reference/api/typescript/aspire.hosting.python.md)
- Version: `13.4.0`
- Kind: `method`
- Source: [GitHub](https://github.com/microsoft/aspire)

Configures a custom virtual environment path for the Python application.

## Definition

```typescript
interface PythonAppResource {
  // ... omitted for brevity
  withVirtualEnvironment(
    virtualEnvironmentPath: string,
    createIfNotExists?: boolean): PythonAppResource
}
```

## Parameters

- `virtualEnvironmentPath` (`string`)
- `createIfNotExists` (`boolean`) `optional` `= True`

## Returns

[PythonAppResource](/reference/api/typescript/aspire.hosting.python/pythonappresource.md) `builder`

## Applies to

- [PythonAppResource](/reference/api/typescript/aspire.hosting.python/pythonappresource.md)
- [UvicornAppResource](/reference/api/typescript/aspire.hosting.python/uvicornappresource.md)
