# Setting Fiddler alongside Python applications

**Q:** How can I capture traffic from Python applications?
**Q:** When Fiddler Everywhere acts as a system proxy, I cannot use python's pip library (or other Python library that makes HTTPS requests).
**Q.** My python library fails with `CERTIFICATE_VERIFY_FAILED` when Fiddler is an intermediate proxy.

## Using Fiddler Terminal

The Fiddler Everywhere application allows starting a dedicated terminal that automatically proxies HTTPS requests through the Fiddler proxy. The Fiddler terminal supports capturing from Python applications without additional configuration - Fiddler Everywhere sets everything.

> important Fiddler Everywhere terminal supports Python version 3 and above, which was first introduced in 2009. Older versions of Python are unsupported.

Steps needed to capture HTTPS traffic from a Python application:

1. Start the Fiddler Everywhere application.
2. Click **Open Terminal** to start dedicated terminal instance.
3. Run the Python app within the dedicated terminal instance.

[Learn more about the **Open Browser** option in Fiddler Everywhere here...](https://www.telerik.com/fiddler/fiddler-everywhere/documentation/capture-traffic/capturing-traffic-from-terminal)

## Setting Fiddler Proxy and CA Through Environment Variables

As an alternative to the preconfigured terminal, you can configure your python applications to go through the Fiddler Everywhere proxy explicitly.

For Fiddler Everywhere to capture traffic from a Python application, the application must be configured to respect the Fiddler Everywhere proxy. You can achieve that by setting the environment variables `http_proxy` and `https_proxy`. The `export` command (for macOS and Linux) or the `set` command (for Windows). The `export` command will generate an environment variable in a child process environment. It does not affect other already-existing settings.

The following example demonstrates how to define the proxy settings through environmental variables on **macOS** and **Linux**. Note that you need to have the Fiddler root CA exported to the Desktop folder through **Settings** > **HTTPS** > **Advanced** > **Export Root Certificate (PEM/ASCII)**.

\*\*

```sh
export http_proxy=http://127.0.0.1:8866
export https_proxy=http://127.0.0.1:8866
export SSL_CERT_FILE=~/Desktop/Fiddler_Root_Certificate_Authority.pem
export REQUESTS_CA_BUNDLE=~/Desktop/Fiddler_Root_Certificate_Authority.pem
```

The following example demonstrates how to define the proxy settings through environmental variables on **Windows**. Note that you need to have the Fiddler root CA exported to the Desktop folder through **Settings** > **HTTPS** > **Advanced** > **Export Root Certificate (PEM/ASCII)**.

```sh
set http_proxy=http://127.0.0.1:8866
set https_proxy=http://127.0.0.1:8866
set SSL_CERT_FILE=~/Desktop/Fiddler_Root_Certificate_Authority.pem
set REQUESTS_CA_BUNDLE=~/Desktop/Fiddler_Root_Certificate_Authority.pem
```

Once the Fiddler Everywhere proxy is set, you can immediately capture traffic through the Python application.

### Resetting Fiddler Proxy

Once debugging with Fiddler Everywhere, reset the current environment proxy by removing the Fiddler Everywhere proxy variables. You can use the `unset` command on macOS and Linux to achieve that. On Windows, you need to set an empty string.

The following example demonstrates how to unset the proxy on **macOS** and **Linux**.

```sh
unset http_proxy
unset https_proxy
```

The following example demonstrates how to unset the proxy on **Windows**.

```sh
set http_proxy=
set https_proxy=
```

## Setting Fiddler Proxy Through Python Code

You can set the Fiddler proxy explicitly through the Python application's code base.

```python
import requests

proxies = {'http': '127.0.0.1:8866', 'https': '127.0.0.1:8866'}
r = requests.get('https://reqbin.com/echo', proxies=proxies)
```

## See Also

[Learn how to export the Fiddler CA certificate as PEM here...](https://www.telerik.com/fiddler/fiddler-everywhere/documentation/knowledge-base/how-to-create-pem)
