Ubuntu package "python3" does not include tkinter

Steven D'Aprano steve+comp.lang.python at pearwood.info
Tue Apr 23 01:49:09 EDT 2013


On Mon, 22 Apr 2013 19:47:26 -0500, Andrew Berg wrote:

> On 2013.04.22 19:22, Steven D'Aprano wrote:
>> It's only when I actually try to do something that requires an X
>> display that it will fail. I won't show the entire traceback, because
>> it is long and not particularly enlightening, but the final error
>> message explains exactly why it isn't working:
>> 
>> _tkinter.TclError: no display name and no $DISPLAY environment variable
>
> So you want to go from "this won't work because it's not installed" to
> "this won't work, and it there could be a hundred different reasons
> why"? 

No, that's not what I said. I want to go from:

"this won't work because it's not installed, and I have no idea how to 
install it or what dependencies are needed, and even when I meet all the 
dependencies and install it, it might still not work"

to:

"this won't work, and here are the reasons why".


Splitting tkinter out into an extra package doesn't buy you much, if 
anything. Here is the error I get on Debian when I try importing tkinter:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/lib/python3.1/tkinter/__init__.py", line 42, in <module>
    raise ImportError(str(msg) + ', please install the python-tk package')
ImportError: No module named _tkinter, please install the python-tk 
package


This implies that the pure Python parts of tkinter are already installed. 
It's just the magic _tkinter module which isn't included.

(Also, many points for actually telling me what I need to do to fix the 
problem.)


> tkinter's main function is to display something on a display. To
> say that displaying something is an optional feature is absurd.

Of course it is optional. Python will run on headless systems, or before 
X starts up, or on systems where there is no X. Importing tkinter works 
before X starts up. There's *no reason why* importing tkinter ought to 
fail before X starts up. Obviously you cannot display an X window without 
X, well duh, but merely importing tkinter doesn't require an X display.


> "You can
> install this, but your package manager won't pull in any dependencies
> because a few minor things will work without them. If you want it to
> actually do what it was made for, you need to install them yourself."
> Much bigger problem than the OP's, no?

Not necessarily bigger, just different.

I don't see why "apt-get install python-tk" is considered too trivial to 
worry about, but "apt-get install tcl" is considered a "much bigger 
problem". So long as the error tells you what to do, they're both more or 
less equally hard. Or easy. 

We agree on the conditions needed to display tkinter GUI windows:

- you must have Python
- and the tkinter package
- and the _tkinter module
- and Tk/Tcl
- and X

(and an OS, and a computer, and electricity, but we can take them as 
given).

We just disagree on where to break the packages up. Debian appears to do 
this:

(Python tkinter) (_tkinter) (Tk/Tcl) (X)


Ubuntu appears to do this, I think:

(Python) (tkinter _tkinter) (Tk/Tcl) (X)

I'm suggesting there's no real harm in doing this:

(Python tkinter _tkinter) (Tk/Tcl) (X)


for standard desktop installs, and some minor advantages.


-- 
Steven



More information about the Python-list mailing list