Search overlay panel for performing site-wide searches

Salesforce (Heroku) Recognized as a Leader. Learn More!

Two intertwined, abstract shapes in blue and yellow against a red background.

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

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

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

Get started now with Python on Heroku

Deploying Python apps with Heroku

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

View Python Docs

Heroku gives you simple, easy ways to…

Be in the Flow

Collaborating easily, testing early, and deploying often are all part of Heroku Flow: Heroku Pipelines streamline your workflow, Heroku Review Apps auto-deploy your PRs, Heroku CI tests anything you push to GitHub, and much more.

Continuous Delivery on Heroku

Architect and scale

The Heroku runtime makes it easy to deploy loosely coupled services that run in lightweight, isolated Linux containers known as dynos. The architecture of the Heroku platform encourages best practices that ensure durability and scalability.

Heroku Platform Principles

Extend and grow

Extend your app with relational databases like PostgreSQL or MySQL, leverage NoSQL data stores such as Redis® or MongoDB, stream events into Apache Kafka or an AMQP server, send emails, monitor your app – with 200+ add-ons, the possibilities are limitless.

Heroku Add-ons

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.

Ed Morley

Python Language Owner

Heroku Python Support FAQ

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.

The fastest way to get started is by following the official Getting Started on Heroku 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.

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.

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.

A 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

Django does not support serving static files directly in a production environment; a dedicated solution is required. The recommended and most common solution on Heroku is to use the WhiteNoise library.

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.

Yes, you can. This is a common and powerful feature of the Heroku platform, handled by the Heroku CLI. Using the heroku run command, you can start a new instance of your application’s environment (called a one-off dyno) 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.

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 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 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