Does anyone happen to know how I can install tkMessageBox on Python2.7? I'm trying to run some Tkinter scripts that I've found, and I need the tkMessageBox to do so. I tried "pip install tkMessageBox" and got a message that said no package by that name could be found. I also tried looking on Christoph Gohlke's site for an installer, but no luck. I've read that tkMessageBox has changed names in Python3.x--can I pip install it by using a different name? Any help others can offer would be most appreciated. (In case it matters, I'm working in Windows 8.)
It comes with Tkinter, it's not a separate package. If you have tkinter, you have tkmessagebox. However, it has been renamed in python 3
python 2.x:
import Tkinter
import tkMessageBox
python 3.x:
from tkinter import messagebox as tkMessageBox
Related
Running python3 to bring me into python, and then simply running import tkinter results in the following error:
File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/tkinter/__init__.py", line 36, in <module>
import _tkinter # If this fails your Python may not be configured for Tk
ModuleNotFoundError: No module named '_tkinter'
However when going into the python shell (not python3), import tkinter works fine as expected. How can I get tkinter to work with Python3?
Please note the following:
I am on MacOS Catalina
I am working with Python 3.7.3 (based off python3 --version)
It looks like my python3 executable is (/usr/bin/python3)
The path for tkinter is /Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/tkinter/
I am able to run idle in Terminal, but I can't run idle3
I don't think I am using a virtualenv or pyenv or anything like that
You need a separate Tcl/Tk installation. Try a newer version of the Python3 binary installer from python.org, which bundles Tcl/Tk.
Don't install tkinter through idle. Try idle3. If nothing, install python3-tk using your OS installer. (I have apt. I'm on Debian.). Good luck!
Don't use _ in import _tkinter
Use import tkinter
I am Sure that this will work. If it works then tick my answer.
Fist open Command Prompt and run pip install tkinter
Then open your python project and press Ctrl + S.
Then run your project.
I hope my answer is useful to you.
I had been using Python2.7 on Windows 10 (64-bit). I recently decided to upgrade to 3.0 to update some legacy scripts.
I uninstalled Python27, and installed Python30 (I know I could supposedly run them concurrently on the same system, but I chose not to use that as a crutch) and updated the Windows %PATH%
My old scripts used ttk (import ttk).
I updated to use "from tkinter import ttk", but now I'm getting "cannot import name ttk". I'm assuming it's still somehow trying to link to the 2.7 Tkinter that no longer exists (and didn't contain ttk as a submodule since it was 2.7).
How can I get ttk to link correctly under Python3 after having used 2.7?
hey i'am new in programming ..
I am doing a mini project in python in pycharm..
I am getting an error which says Tkinter module not installed..
plzz anybody can help..!!
in case of Python3.6, tkinter is a part of the standard library available from when you install your python. However if you want to know if tkinter is installed just import it in the python console
import tkinter
if you didn't see any errors you are good to go.
I'll preface this by saying that I am aware that on 2.7 it should be:
import Tkinter
However, for whatever reason on my desktop running xenial and
python --version
returning:
python 2.7.12
I have had no trouble throughout the development of an application on my system importing tkinter with
import tkinter
I am wholly confused because as I went to work on a different machine I attempted to run my code only to find out I should have been using
import Tkinter
Which executes fine on the second machine. However,
import tkinter
returns that there is no module named tkinter.
Does anybody know why this is happening?
You must have installed the six module at some point. It includes a dummy tkinter that allows python3 style tkinter imports in python2.
Has anyone else had this problem? I have re-installed twice with the same result. The pre-install of 2.6 on the Mac had a lib-tk folder with the correct modules. Nothing like this is being created for 3.1. There is a Tkinter folder but it contains only a few obscure modules. Importing _tkinter and tkinter works but not Tkinter and all of the example programs fail.
Tkinter was substantially refactored in Python 3 from a set of modules into packages. Tkinter is now tkinter and the lib-tk folder no longer exists. At least some of the example tkinter programs included in the OS X 3.1 distribution work if you ensure they are being launched under Python 3 and not Python 2. See the Python 3.1 library reference.