tkinter import problems on mac - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: GUI (https://python-forum.io/forum-10.html) +--- Thread: tkinter import problems on mac (/thread-4215.html) |
tkinter import problems on mac - Lux - Jul-30-2017 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 ScrolledTextAt 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 scrolledtextI 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? RE: tkinter import problems on mac - Barrowman - Jul-30-2017 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 mycode.py if it's tkinter in your code try python3 mycode.pyfrom the terminal You might need to give the path to the code. RE: tkinter import problems on mac - Larz60+ - Jul-30-2017 you can use: try: import tkinter except ImportError: import Tkinter1st case for python 3, 2nd for 2.7 reverse if you mainly use 2.7 |