Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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

share|improve this question
add comment

1 Answer

up vote 4 down vote accepted

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.

share|improve this answer
    
I was looking for a way to create python3 applications rather than having to change them manually after creation but I tried that in a clean new application and got this error: Traceback (most recent call last): File "bin/foo", line 32, in <module> import foo File "/home/William/Programming/foo/foo/__init__.py", line 12, in <module> from gi.repository import Gtk # pylint: disable=E0611 ImportError: No module named gi.repository –  William May 10 '13 at 1:31
    
You need to install the Python 3 bindings for the gobject-introspection libraries: sudo apt-get install python3-gi. AFAIK this is the only way to create a Python 3 application with Quickly. –  tectux May 10 '13 at 8:01
    
Thanks for the heads up, installing the library did solve the problem. Now I get errors with the code even when strictly following the "quickly tutorial" but I guess that must be because the tutorial is in python 2.7. Anyway, thanks, your method works –  William May 10 '13 at 13:24
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.