1 The Short Explanation 2 Details 2.1 Drop support for Python 2.6 and older 2 But you should aim for only supporting Python 2.7. Python 2.6 is no longer freely supported and thus is not receiving bugfixes. This means you will have to work around any issues you come across with Python 2.6. There are also some tools mentioned in this HOWTO which do not support Python 2.6 (e.g., Pylint), and this will become more commonplace as time goes on. It will simply be easier for you if you only support the versions of Python that you have to support. If you are able to skip Python 2.5 and older, then the required changes to your code should continue to look and feel like idiomatic Python code. At worst you will have to use a function instead of a method in some instances or have to import a function instead of using a built-in one, but otherwise the overall transformation should not feel foreign to you. While you can make Python 2.5 work with Python 3, it is much easier if you only have to work with Python 2.7. If dropping Python 2.5 is not an option then the six project can help you support Python 2.5 & 3 simultaneously ($_{python -m pip install six}$ ). Do realize, though, that nearly all the projects listed in this HOWTO will not be available to you. A key point about supporting Python 2 & 3 simultaneously is that you can start today ! Even if your dependencies are not supporting Python 3 yet that does not mean you can’t modernize your code now to support Python 3. Most changes required to support Python 3 lead to cleaner code using newer practices even in Python 2 code. Another key point is that modernizing your Python 2 code to also support Python 3 is largely automated for you. While you might have to make some API decisions thanks to Python 3 clarifying text data versus binary data, the lower-level work is now mostly done for you and thus can at least benefit from the automated changes immediately. Keep those key points in mind while you read on about the details of porting your code to support Python 2 & 3 simultaneously. Note: Note: Using$_{python -m pip install}$ guarantees that the$_{pip}$ you invoke is the one installed for the Python currently in use, whether it be a system-wide$_{pip}$ or one installed within a virtual environment. 8. Consider using optional static type checking to make sure your type usage works in both Python 2 & 3 (e.g. use mypy to check your typing under both Python 2 & Python 3;$_{python -m pip install mypy}$ ). 7. Once your dependencies are no longer blocking you, use continuous integration to make sure you stay compat- ible with Python 2 & 3 (tox can help test against multiple versions of Python;$_{python -m pip install}$ $_{tox}$) 6. Use caniusepython3 to find out which of your dependencies are blocking your use of Python 3 ( python -m pip install caniusepython3 ) 5. Use Pylint to help make sure you don’t regress on your Python 3 support ( python -m pip install pylint ) 3. Learn the differences between Python 2 & 3 4. Use Futurize (or Modernize) to update your code (e.g.$_{python -m pip install future}$ ) 2. Make sure you have good test coverage (coverage.py can help;$_{python -m pip install coverage}$ ) 1. Only worry about supporting Python 2.7 To make your project be single-source Python 2/3 compatible, the basic steps are: