Skip Navigation
Show nav
Heroku Dev Center
  • Get Started
  • Documentation
  • Changelog
  • Search
  • Get Started
    • Node.js
    • Ruby on Rails
    • Ruby
    • Python
    • Java
    • PHP
    • Go
    • Scala
    • Clojure
  • Documentation
  • Changelog
  • More
    Additional Resources
    • Home
    • Elements
    • Products
    • Pricing
    • Careers
    • Help
    • Status
    • Events
    • Podcasts
    • Compliance Center
    Heroku Blog

    Heroku Blog

    Find out what's new with Heroku on our blog.

    Visit Blog
  • Log inorSign up
View categories

Categories

  • Heroku Architecture
    • Dynos (app containers)
    • Stacks (operating system images)
    • Networking & DNS
    • Platform Policies
    • Platform Principles
  • Command Line
  • Deployment
    • Deploying with Git
    • Deploying with Docker
    • Deployment Integrations
  • Continuous Delivery
    • Continuous Integration
  • Language Support
    • Node.js
    • Ruby
      • Working with Bundler
      • Rails Support
    • Python
      • Background Jobs in Python
      • Working with Django
    • Java
      • Working with Maven
      • Java Database Operations
      • Working with the Play Framework
      • Working with Spring Boot
      • Java Advanced Topics
    • PHP
    • Go
      • Go Dependency Management
    • Scala
    • Clojure
  • Databases & Data Management
    • Heroku Postgres
      • Postgres Basics
      • Postgres Getting Started
      • Postgres Performance
      • Postgres Data Transfer & Preservation
      • Postgres Availability
      • Postgres Special Topics
    • Heroku Data For Redis
    • Apache Kafka on Heroku
    • Other Data Stores
  • Monitoring & Metrics
    • Logging
  • App Performance
  • Add-ons
    • All Add-ons
  • Collaboration
  • Security
    • App Security
    • Identities & Authentication
    • Compliance
  • Heroku Enterprise
    • Private Spaces
      • Infrastructure Networking
    • Enterprise Accounts
    • Enterprise Teams
    • Heroku Connect (Salesforce sync)
      • Heroku Connect Administration
      • Heroku Connect Reference
      • Heroku Connect Troubleshooting
    • Single Sign-on (SSO)
  • Patterns & Best Practices
  • Extending Heroku
    • Platform API
    • App Webhooks
    • Heroku Labs
    • Building Add-ons
      • Add-on Development Tasks
      • Add-on APIs
      • Add-on Guidelines & Requirements
    • Building CLI Plugins
    • Developing Buildpacks
    • Dev Center
  • Accounts & Billing
  • Troubleshooting & Support
  • Integrating with Salesforce
  • Language Support
  • Python
  • Python 2.7 EOL FAQ

Python 2.7 EOL FAQ

English — 日本語に切り替える

Last updated October 13, 2022

Table of Contents

  • Why is Python 2 being sunset?
  • What Heroku stack versions support Python 2?
  • What will happen to existing Python 2 apps on Heroku?
  • Will Python 2 apps still receive technical support?
  • How do I migrate my application to Python 3?
  • I’m not going to be able to migrate to Python 3, what are my options?
  • How do I switch to a Python buildpack version that still supports Python 2?

Why is Python 2 being sunset?

Python 2 was superseded by Python 3 many years ago, and as such the upstream Python project officially ended support for Python 2 on January 1st, 2020, after several extensions to the sunset date. This means no new versions of Python 2 are being released upstream, so it no longer receives security or bug fixes.

What Heroku stack versions support Python 2?

Python 2 is only supported on Heroku’s oldest stack, Heroku-18, which is deprecated and reaches end-of-life on April 30th, 2023.

What will happen to existing Python 2 apps on Heroku?

Existing Python 2.7 applications on Heroku will continue to run for the foreseeable future (unless impacted by issues unrelated to the Python version).

However:

  • Since Python 2 has not received security fixes since 2020, it contains several unfixed security vulnerabilities, and so customers are strongly encouraged to migrate to a newer Python version to keep their applications secure.
  • The latest version of the Python buildpack no longer supports Python 2, so apps must switch to an older buildpack version in order for builds to work (see How do I switch to a Python buildpack version that still supports Python 2?).
  • Once the deprecated Heroku-18 stack reaches the end of it’s life on April 30th, 2023, further builds (code deployments) of Python 2 apps will no longer be possible (even when using the older buildpack version), since newer stacks do not support Python 2. See the Heroku-18 End-of-Life FAQ for more details.

Will Python 2 apps still receive technical support?

End of life language versions fall outside of Heroku’s Support Policy, and so Python 2 applications are no longer eligible for technical support without first upgrading to a supported version of Python.

How do I migrate my application to Python 3?

See the upstream Python project’s guide to Porting Python 2 Code to Python 3.

Once your application has been made compatible with Python 3 locally, you will then need to ensure that Heroku builds your application using Python 3. See Specifying a Python Runtime and supported Python versions.

I’m not going to be able to migrate to Python 3, what are my options?

Python 2 contains several unfixed security vulnerabilities, and so customers are strongly encouraged to migrate to a newer Python version to keep their applications secure. However, if you are willing to accept this risk there are two ways you can continue to use Python 2:

  1. If your application does not need any further code changes/new deployments, you can continue using your existing Python 2 application even after the end-of-life of the Heroku-18 stack with no changes required (see the Heroku-18 End-of-Life FAQ for more details).
  2. However, if you wish to continue performing new code deployments after the Heroku-18 stack reaches end-of-life (on April 30th, 2023), one alternative would be to migrate to Heroku’s container stack instead, and use the legacy python:2.7 Docker images (note: these Docker images have not received security updates since 2020 either). See:
    • Deploying with Docker
    • Python 2.7 Docker images

How do I switch to a Python buildpack version that still supports Python 2?

The latest version of the Heroku Python buildpack (the component responsible for transforming your source code into a deployable application) no longer supports Python 2 as of September 26th, 2022.

Therefore, in order to continue to build Python 2 applications (until the end-of-life of Heroku-18), you will need to switch to an older version of the Python buildpack. Note: This should only be used as a temporary solution until either the app is upgraded to Python 3, or one of the longer-term workarounds above is used.

To do this, follow the steps at Checking the Python buildpack version, except instead of specifying a buildpack URL of heroku/python, use the URL https://github.com/heroku/heroku-buildpack-python#v218 instead, which will mean your app will use version 218 of the buildpack (the last to support Python 2).

Once you have upgraded your app to Python 3, make sure to undo this change, by following the same process and switching back to a buildpack URL of heroku/python, to ensure you receive future fixes and updates to the Python buildpack.

Keep reading

  • Python

Feedback

Log in to submit feedback.

Specifying a Python Runtime Python Dependencies via Pip

Information & Support

  • Getting Started
  • Documentation
  • Changelog
  • Compliance Center
  • Training & Education
  • Blog
  • Podcasts
  • Support Channels
  • Status

Language Reference

  • Node.js
  • Ruby
  • Java
  • PHP
  • Python
  • Go
  • Scala
  • Clojure

Other Resources

  • Careers
  • Elements
  • Products
  • Pricing

Subscribe to our monthly newsletter

Your email address:

  • RSS
    • Dev Center Articles
    • Dev Center Changelog
    • Heroku Blog
    • Heroku News Blog
    • Heroku Engineering Blog
  • Heroku Podcasts
  • Twitter
    • Dev Center Articles
    • Dev Center Changelog
    • Heroku
    • Heroku Status
  • Facebook
  • Instagram
  • Github
  • LinkedIn
  • YouTube
Heroku is acompany

 © Salesforce.com

  • heroku.com
  • Terms of Service
  • Privacy
  • Cookies
  • Cookie Preferences