By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,621 Members | 1,104 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,621 IT Pros & Developers. It's quick & easy.

Configuring Python for Tk on Mac

P: n/a
On my desk here at work I have a Mac G4 running Mac OS X v10.2.8.

When I go into a terminal and type "python" up comes a nice python
interface and all seems great. However when I type "import Tkinter"
I'm greeted by the following error.
import Tkinter

Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "/usr/lib/python2.2/lib-tk/Tkinter.py", line 35, in ?
import _tkinter # If this fails your Python may not be configured
for Tk
ImportError: No module named _tkinter

So I guess something about this implementation is not appropriately
configured. I'm guessing this is the default behaviour since I don't
think anyone did anything special about python when they set up my
machine.

What do I do to set it up so I can use Tkinter?

Thanks... and sorry if this is an FAQ... but I couldn't find the info
easily.

Yours,
Martyn
Jul 18 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
I googled around and it looks like it might be a permissions error:
http://mail.python.org/pipermail/pyt...er/006809.html
I don't have a Mac, tho', so I have no idea if it works...
HTH

Jul 18 '05 #2

P: n/a
On Fri, 2005-01-21 at 07:39 -0800, Martyn Quick wrote:
On my desk here at work I have a Mac G4 running Mac OS X v10.2.8.

When I go into a terminal and type "python" up comes a nice python
interface and all seems great. However when I type "import Tkinter"
I'm greeted by the following error.
import Tkinter
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "/usr/lib/python2.2/lib-tk/Tkinter.py", line 35, in ?
import _tkinter # If this fails your Python may not be configured
for Tk
ImportError: No module named _tkinter

So I guess something about this implementation is not appropriately
configured.


In general, that error means that Python can't find the C extension
module used to provide the low-level interface for Tkinter. It's not
installed, can't be found (library path or python path issues), can't be
opened (permissions), etc.

Note the comment in the error message to that effect.

I've just checked the OSX 10.3 machine here, and it fails to import
tkinter there too. I'd say Apple just don't build Python with Tk
support.
What do I do to set it up so I can use Tkinter?


Try Google - this seems to be a moderately FAQ for MacOS/X.

--
Craig Ringer

Jul 18 '05 #3

P: n/a
Martyn Quick wrote:
On my desk here at work I have a Mac G4 running Mac OS X v10.2.8.

When I go into a terminal and type "python" up comes a nice python
interface and all seems great. However when I type "import Tkinter"
I'm greeted by the following error.

import Tkinter


Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "/usr/lib/python2.2/lib-tk/Tkinter.py", line 35, in ?
import _tkinter # If this fails your Python may not be configured
for Tk
ImportError: No module named _tkinter

So I guess something about this implementation is not appropriately
configured. I'm guessing this is the default behaviour since I don't
think anyone did anything special about python when they set up my
machine.

What do I do to set it up so I can use Tkinter?

Thanks... and sorry if this is an FAQ... but I couldn't find the info
easily.

Yours,
Martyn

You probably need to install Tcl/Tk Aqua:
http://tcltkaqua.sourceforge.net

After downloading and installing on my Mac running OS X v 10.2, I am
able to open IDLE and other Tk apps.

HTH,

Jim Sizelove
Jul 18 '05 #4

P: n/a
Craig Ringer <cr***@postnewspapers.com.au> wrote:
...
I've just checked the OSX 10.3 machine here, and it fails to import
tkinter there too. I'd say Apple just don't build Python with Tk
support.


No idea about any 10.2, sorry, but on 10.3 that's not the problem: Tk
support is there alright, it's Tcl/Tk which _isn't_. Get MacPython, its
PackageManager will explain where to get Tcl/Tk Aqua from, as a prereq
for Tkinter and IDLE!
Alex
Jul 18 '05 #5

P: n/a
In article <d1**************************@posting.google.com >,
ma**********@yahoo.co.uk (Martyn Quick) wrote:
On my desk here at work I have a Mac G4 running Mac OS X v10.2.8.

When I go into a terminal and type "python" up comes a nice python
interface and all seems great. However when I type "import Tkinter"
I'm greeted by the following error....


Assuming you are running MacPython from
<http://homepages.cwi.nl/~jack/macpython/macpython-osx.html>...

Install Aqua Tcl/Tk as another poster suggested.

Run Applications/MacPython.../Package Manager and install Tkinter.

Or if your MacPython is out of date, you may just want to download and
install the current version. If Tcl/Tk is already installed then I think
it will install Tkinter automatically (but if not, use Package Manager).

If you are running some other python, please tell us more about it. (If
it's fink python, install the version that includes Tkinter support, but
this runs on X11 instead of Aqua).

-- Russell
Jul 18 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.