---
"title": "Python"
"description": "Build Python apps and APIs on the Heroku platform using Django, FastAPI, or Flask. Get build and workflow support; extend your app with 150+ add-ons."
"date": "2025-01-10"
"authors":
  -
    "name": "Heroku"
"url": "https://www.heroku.com/python/"
---

![Two intertwined, abstract shapes in blue and yellow against a red background.](https://www.heroku.com/wp-content/uploads/2025/03/python-logo-icon.png)

# Cloud platform for building Pythonic apps and APIs

## The platform for Python that *just works*

### Powerful Ecosystem

Build opinionated MVC web apps with Django, powerful APIs with FastAPI, or process background jobs with Celery. Run your apps with Gunicorn, Uvicorn, or any other ASGI/WSGI server – the choice is yours!

[Python Support on Heroku](https://devcenter.heroku.com/articles/python-support)

### Fast Deploys

Deploy from Git, your CI system, or on every push to a branch on GitHub. Dependency installs are always consistent with your local environment thanks to transparent support for pip freeze.

[Getting Started with Python](https://devcenter.heroku.com/articles/getting-started-with-python)

### Easy Scaling

Heroku’s stateless architecture is ideal for horizontal scaling of services. Issue a command or drag a slider to add capacity. Using larger dynos? Gunicorn will auto-adjust the number of worker processes it spawns.

[Scaling Your Dyno Formation](https://devcenter.heroku.com/articles/scaling)

## Get started now with Python on Heroku

[Sign Up](https://signup.heroku.com/python)

[Video](https://youtu.be/mrFYfG-Vu7Y)

## Deploying Python apps with Heroku

- `CODE_OPEN`uv init`CODE_CLOSE` initializes the Python project and Git repository
- Add Flask as a project dependency
- Update `CODE_OPEN`main.py`CODE_CLOSE` to respond to requests with “Hello Heroku!”
- Create a `CODE_OPEN`Procfile`CODE_CLOSE` to declare the web process
- Create and deploy the app to Heroku
- We’re live! `CODE_OPEN`curl https://stormy-escarpment-95361-6c245e7b263a.herokuapp.com`CODE_CLOSE`

[View Python Docs](https://devcenter.heroku.com/categories/python)

## Heroku gives you simple, easy ways to…

### Be in the Flow

Collaborating easily, testing early, and deploying often are all part of [Heroku Flow](https://www.heroku.com/flow/): [Heroku Pipelines](https://devcenter.heroku.com/articles/pipelines) streamline your workflow, [Heroku Review Apps](https://devcenter.heroku.com/articles/github-integration-review-apps) auto-deploy your PRs, [Heroku CI](https://devcenter.heroku.com/articles/heroku-ci) tests anything you push to GitHub, and much more.

[Continuous Delivery on Heroku](https://www.heroku.com/continuous-delivery/)

### Architect and scale

The Heroku runtime makes it easy to deploy loosely coupled services that run in lightweight, isolated Linux containers known as [dynos](https://www.heroku.com/dynos/). The architecture of the Heroku platform encourages best practices that ensure durability and scalability.

[Heroku Platform Principles](https://devcenter.heroku.com/categories/platform-principles)

### Extend and grow

Extend your app with relational databases like [PostgreSQL](https://elements.heroku.com/addons/heroku-postgresql) or MySQL, leverage NoSQL data stores such as [Redis®](https://elements.heroku.com/addons/heroku-redis) or MongoDB, stream events into [Apache Kafka](https://elements.heroku.com/addons/heroku-kafka) or an AMQP server, send emails, monitor your app – with 200+ add-ons, the possibilities are limitless.

[Heroku Add-ons](https://elements.heroku.com/addons)

![](https://www.heroku.com/wp-content/uploads/2025/03/python-logo-300x80.png)

## Python on Heroku

> “As the Zen of Python says, ‘Simple is better than complex’, and that’s what it’s like deploying Python applications to Heroku.”

![Man taking a selfie with a mountainous landscape in the background under a clear blue sky.](https://www.heroku.com/wp-content/uploads/2025/03/avatar_edmorley.jpg)

Ed Morley

Python Language Owner

[@edmorley](https://github.com/edmorley)

### [Documentation](https://devcenter.heroku.com/categories/python)

- [How Heroku Works](https://devcenter.heroku.com/articles/how-heroku-works)
- [Getting Started with Python on Heroku](https://devcenter.heroku.com/articles/getting-started-with-python)
- [Deploy an Existing Python App to Heroku](https://devcenter.heroku.com/articles/deploying-python)

### [Tutorials & Help](https://devcenter.heroku.com/categories/python)

- [Deploying Python Applications with Gunicorn](https://devcenter.heroku.com/articles/python-gunicorn)
- [Using RQ (Redis Queue) with Python](https://devcenter.heroku.com/articles/python-rq)
- [Understanding Concurrency in Python Apps](https://devcenter.heroku.com/articles/python-concurrency)
- [Using WebSockets with Python](https://devcenter.heroku.com/articles/python-websockets)

## Heroku Python Support FAQ

### How does Heroku manage Python dependencies?

Heroku manages Python dependencies using either **pip**, **Pipenv**, **Poetry**, or **uv**. When you deploy, the buildpack looks for a `requirements.txt`, `Pipfile.lock`, `poetry.lock` or `uv.lock` file to determine which package manager to use. The buildpack then installs the exact packages and versions your application needs, creating a predictable and reliable environment.

If you don’t have a preference, Heroku recommends managing your Python dependencies with **uv**. You can get started with **uv** by [following this uv blog post](https://www.heroku.com/blog/local-speed-smooth-deploys-heroku-adds-support-uv/).

### What is the fastest way to deploy a sample Python application to Heroku?

The fastest way to get started is by following the official [**Getting Started on Heroku with Python**](https://devcenter.heroku.com/articles/getting-started-with-python) guide in the Heroku Dev Center. This tutorial provides a sample application and walks you through the steps of setting up a virtual environment, managing dependencies, and deploying your code with a simple `git push heroku main` command.

### Which Python versions are supported on Heroku?

Heroku’s Python support policy is aligned with the official Python Version Lifecycle. All modern, stable versions of Python are supported, but versions are deprecated as they approach upstream end-of-life (EOL), and support for them is removed from the Python buildpack shortly after EOL occurs.

You can specify the exact version your app requires by creating a `.python-version` file in the root of your project.

### What are the most popular Python frameworks to deploy on Heroku?

Heroku supports the entire Python web ecosystem. It offers robust support for major frameworks like **Django** and **Flask**. Additionally, modern ASGI frameworks like **FastAPI** are excellent choices for building high-performance APIs on Heroku.

### What is a Procfile, and is it required for Python apps?

A [Procfile](https://devcenter.heroku.com/articles/procfile) is a simple text file, named `Procfile` *without a file extension*, that you place in your project's root directory to explicitly declare what commands Heroku should run for your application. It allows you to define one or more process types, such as a web process for your web server or a worker process for a background job.

For a typical **Django** or **Flask** application using the Gunicorn server, a Procfile would look like this:

```
web: gunicorn your_project.wsgi
```

### How should I handle static assets (like CSS and JavaScript) in a Django application on Heroku?

**Django** does not support [serving static files](https://devcenter.heroku.com/articles/django-assets) directly in a production environment; a dedicated solution is required. The recommended and most common solution on Heroku is to use the [**WhiteNoise** library](https://pypi.org/project/whitenoise/).

**WhiteNoise** allows your web application to serve its own static files efficiently in production. During deployment, Heroku's Python buildpack automatically runs the `collectstatic` command to gather all your static assets, and WhiteNoise handles the rest. This is the simplest and most reliable method for managing Django static files on Heroku.

### Can I run a Python shell or a management command on my running Heroku app?

Yes, you can. This is a common and powerful feature of the Heroku platform, handled by the [Heroku CLI](https://devcenter.heroku.com/articles/heroku-cli). Using the `heroku run` command, you can start a new instance of your application's environment (called a [one-off dyno](https://devcenter.heroku.com/articles/one-off-dynos)) to execute commands. For example, you can open an interactive Python shell with `heroku run python` or run a Django database migration with `heroku run python manage.py migrate`. This is extremely useful for debugging, running administrative tasks, and managing your database.

You can also get a plain interactive shell by running `heroku run bash` that will allow you to inspect the contents of your application using common terminal commands such as `cat` and `ls -la`.

### Can I deploy data science and machine learning models with Python on Heroku?

Yes. You can deploy Python applications that handle a wide range of data science tasks on Heroku dynos. This includes everything from data manipulation and analysis using libraries like **Pandas** and **NumPy**, to deploying machine learning models built with **Scikit-learn** and **Statsmodels** as web APIs.

And for more demanding or production-grade machine learning, Heroku offers dedicated services. [Heroku Managed Inference and Agents](https://www.heroku.com/ai/managed-inference-and-agents/) is specifically designed for deploying and scaling complex models and AI agents with high availability. For large-scale or private compute needs, [MCP on Heroku](https://www.heroku.com/ai/mcp-on-heroku/) provides a secure and powerful environment.

This provides a flexible pathway for your projects. You can begin with standard dynos—a great option for smaller models and prototypes—and then scale up to these dedicated services for serious ML workloads.

## Ready to Get Started?

Stay focused on building great data-driven applications and let Heroku tackle the rest.

[Sign Up Now](https://signup.heroku.com/)