Python Forum
tkinter import problems on mac
Thread Rating:
  • 2 Vote(s) - 2.5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
tkinter import problems on mac
I am working with tkinter, on a mac, and I am having trouble with imports. 
Everything works fine in IDLE, but if I try to run my code in Python Launcher (terminal/command line), I get all sorts of errors.
For example, this works just fine in IDLE:
from tkinter import *
import tkinter.scrolledtext as ScrolledText
At first, the error I got was "no module named tkinter". I finally realized that for it to work in Terminal (at least on my computer), I had to use 
from Tkinter import *
However, now I am getting errors with importing scrolledtext, and I am totally lost. I have tried:
import tkinter.scrolledtext as ScrolledText
import Tkinter.scrolledtext as ScrolledText
from tkinter.scrolledtext import scrolledtext
from Tkinter.scrolledtext import scrolledtext
I know it is possible to create this without scrolledtext, but I would like to avoid that if possible. Is there any way to make ScrolledText import in Terminal?
Tkinter is for python 2
and it's tkinter for python 3
if you have both installed your syntax needs to be such that you run the correct version of python.
On my Linux Mint 18.1 by default I have python 2.7.6
I also have python 3.5.2 installed.
There are some more differences between 2.x and 3.x
if your code is called  if it's tkinter in your code try
from the terminal
You might need to give the path to the code.
you can use:

    import tkinter
except ImportError:
    import Tkinter
1st case for python 3,
2nd for 2.7

reverse if you mainly use 2.7

Possibly Related Threads…
Thread Author Replies Views Last Post
  [TKINTER] Problems creating directories in a selected path Vulera 2 631 Aug-10-2021, 06:38 PM
Last Post: Vulera
  Tkinter having problems with packing labels? wallgraffiti 0 620 Aug-02-2020, 09:26 AM
Last Post: wallgraffiti
  [Tkinter] Problems to display Web Scraping values in Tkinter Lucas_Ribeiro 0 759 May-07-2020, 12:36 AM
Last Post: Lucas_Ribeiro
  [Tkinter] Tkinter - I have problem after import varaible or function from aGUI to script johnjh 2 1,201 Apr-17-2020, 08:12 PM
Last Post: johnjh
  import Tkinter orestgogosha 1 1,203 Mar-27-2020, 03:32 PM
Last Post: DT2000
  IDLE can't import Tkinter turtleman 3 4,303 Jan-17-2020, 05:34 PM
Last Post: turtleman
  [Tkinter] Top Level Window - from tkinter import * francisco_neves2020 6 2,128 Apr-23-2019, 09:27 PM
Last Post: francisco_neves2020
  tkinter frame sizing problems Lux 0 3,616 Aug-26-2017, 06:09 PM
Last Post: Lux

Forum Jump:

User Panel Messages

Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020