# PythonAppResource.withVirtualEnvironment

- Module: [Aspire.Hosting.Python](/reference/api/typescript/aspire.hosting.python.md)
- Defined on: [PythonAppResource](/reference/api/typescript/aspire.hosting.python/pythonappresource.md)
- Version: `13.4.0`
- Kind: `method`

Configures a custom virtual environment path for the Python application.

## Definition

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

## Signature

```typescript
withVirtualEnvironment(
    virtualEnvironmentPath: string,
    createIfNotExists?: boolean): PythonAppResource
```

## Parameters

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

## Returns

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

## Defined on

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