Ubuntu – How to set quickly to use python3 when creating new applications in Ubuntu 12.04

12.04application-developmentpythonquickly

I'm just starting to learn python and use the standard set of tools in ubuntu 12.04 (quickly, glade, gedit).

When I do quickly create ubuntu-application foo the application uses python 2.7 by default.

I would rather use python3 since it's the version I'm learning and the plan is to drop python2 by 14.04.

How do I configure quickly to use python3 when creating new applications? (I already have it installed, but do not want to set it as the default for the entire system to avoid breaking things).

Best Answer

  • Here's how I did it:

    Change #!/usr/bin/python in #!/usr/bin/python3 on the first line of the file foo/bin/foo.

    In the file foo/foo_lib/helpers.py, lines 65-70, change

    # Set the logging level to show debug messages.
    if opts.verbose:
        logger.setLevel(logging.DEBUG)
        logger.debug('logging enabled')
    if opts.verbose > 1:
        lib_logger.setLevel(logging.DEBUG)
    

    in

    # Set the logging level to show debug messages.
    if opts.verbose:
        logger.setLevel(logging.DEBUG)
        logger.debug('logging enabled')
        if opts.verbose > 1:
            lib_logger.setLevel(logging.DEBUG)
    

    to avoid

    TypeError: unorderable types: NoneType() > int()
    

    Also, make sure you have installed the Python 3 bindings for the gobject-introspection libraries.

    sudo apt-get install python3-gi
    

    to avoid import errors for gi.repository.

  • Related Question