# Using Python
source: https://developer.mastercard.com/consent-management/documentation/tutorials/project-setup/python-tutorial-setup/index.md

## Introduction {#introduction}

This section describes the requirements for the Python tutorial and shows how to setup configuration for Mastercard libraries to encrypt and sign requests.

## Prerequisites {#prerequisites}

First you need to create a project on `developer.mastercard.com` as described in [Project
Setup](https://developer.mastercard.com/consent-management/documentation/tutorials/project-setup/index.md). From that you should have a .p12 key
file and a consumer key. You will also need to download the encryption key from the
project page.

This tutorial uses **python 3.6**.

You will need the following Python modules installed:

* [Mastercard API signing library](https://github.com/Mastercard/oauth1-signer-python)
* [Mastercard API encryption library](https://github.com/Mastercard/client-encryption-python)

This tutorial uses [flask](https://flask.palletsprojects.com/en/3.0.x/) framework.
You need to either install that or adjust the code for the library you want to use.

The tutorial sends requests to [Sandbox](https://sandbox.api.mastercard.com).

## API Keys {#api-keys}

Add the encryption and signing keys to `app/config` folder.

Update the properties found in `app/config/application-sandbox.properties`

```python
signing.consumerKey=
signing.pkcs12KeyFile=
signing.keyAlias=
signing.keyPassword=

client.encryption.pemFile=
```

## Run {#run}

Install dependencies:

```bash
pip3 install -r requirements.txt
```

To run the reference app on **sandbox**:

```bash
FLASK_ENV=sandbox FLASK_APP=app/main python3 -m flask run -p 8081
```

To run the reference app on **production**:

```bash
FLASK_ENV=prod FLASK_APP=app/main python3 -m flask run -p 8081
```

### Running with virtualenv: {#running-with-virtualenv}

```bash
python3 -m venv venv
source venv/bin/activate
venv/bin/python3 -m ensurepip --upgrade
venv/bin/python3 -m pip install --upgrade pip
venv/bin/python3 -m pip install -r requirements.txt

FLASK_ENV=sandbox FLASK_APP=app/main venv/bin/python3 -m flask run -p 8081
```

