​​The Cambridge Crystallographic Data Centre (CCDC).
The CCDC websites use cookies. By continuing to browse the site you are agreeing to our use of cookies. For more details about cookies and how to manage them, see our  cookie policy.

How do I port my existing scripts from Python 2.7 to Python 3?


You may wish to consult the official Python Software Foundation's guide.

Hopefully, your script was written with both Python 2.7 and 3.x in mind. The Python-Future's cheat sheet gives practical tips.

If your script does not contain from future import division you will need to very carefully check all of the integer division operations in your code to ensure that results match between Python 2.7 and Python 3.x.


There are some known script changes that are needed if your script makes use of tkinter or winreg, as described below.

For Tkinter, please replace import Tkinter with the following:

    import Tkinter
except ImportError:
    import tkinter as Tkinter
 For winreg, please replace import _winreg with the following:
    import _winreg
except ImportError:
    import winreg as _winreg