Python issue: Getting a "cannot import name ttk" error

Status
Not open for further replies.

davidtheweb

Ars Scholae Palatinae
1,335
As the topic title, I'm receiving a "cannot import name ttk" error even though it appears that my python path has the correct directory listed in it. I'm wondering if I have a configuration or even a permissions issue. Also, although there is a ttk.py file in my python27\lib\lib-tk folder, there isn't a ttk.pyc file in there. I wonder if that's a symptom of the larger problem that's giving me the "cannot import name" error.
 

davidtheweb

Ars Scholae Palatinae
1,335
Odd solution:

I had this before: (it's Python 2, hence the capitalized Tkinter)

from Tkinter import *
from Tkinter import ttk

and I'd get my 'cannot import name ttk' error.

Now I have this after reading about double imports and changing the code:

from Tkinter import *
import ttk

and it works fine!

So I guess I have to watch for double imports.
 
Status
Not open for further replies.