Install tkinter and python locally
Use CPPFLAGS environment variable to set the include directories for tcl and tk before building Python 3. This has worked for me.
export CPPFLAGS="-I/home/sam/install_sam/tcl/include -I/home/sam/install_sam/tk/include"
How to pip or easy_install tkinter on Windows
Well I can see two solutions here:
1) Follow the Docs-Tkinter install for Python (for Windows):
Tkinter (and, since Python 3.1, ttk) are included with all standard Python distributions. It is important that you use a version of Python supporting Tk 8.5 or greater, and ttk. We recommend installing the "ActivePython" distribution from ActiveState, which includes everything you'll need.
In your web browser, go to Activestate.com, and follow along the links to download the Community Edition of ActivePython for Windows. Make sure you're downloading a 3.1 or newer version, not a 2.x version.
Run the installer, and follow along. You'll end up with a fresh install of ActivePython, located in, e.g. C:\python32
. From a Windows command prompt, or the Start Menu's "Run..." command, you should then be able to run a Python shell via:
% C:\python32\python
This should give you the Python command prompt. From the prompt, enter these two commands:
>>> import tkinter
>>> tkinter._test()
This should pop up a small window; the first line at the top of the window should say "This is Tcl/Tk version 8.5"; make sure it is not 8.4!
2) Uninstall 64-bit Python and install 32 bit Python.
Install tkinter for Python
It is not very easy to install Tkinter locally to use with system-provided Python. You may build it from sources, but this is usually not the best idea with a binary package-based distro you're apparently running.
It's safer to apt-get install python-tk
on your machine(s).
(Works on Debian-derived distributions like for Ubuntu; refer to your package manager and package list on other distributions.)
Tkinter install not working after pip install tk
If you are using Python 3, Tkinter is built in. But you have to use a lowercase letter. Don't use "Tkinter", use "tkinter" instead.
Also, don't use "import tkinter", use "from tkinter import *", to import everything.
Example:
from tkinter import *
def command():
print("Hello, world!")
root = Tk()
root.title("tkWindow")
btn = Button(root, text="Click Me!", command=command)
btn.pack()
root.mainloop()
Also, remember that when you import everything from Tkinter (using from tkinter import *), you don't use tk.Tk() or tk.Button(), you just have to use Tk() and Button().
This should work for you. Good luck, and happy coding!
Related Topics
Pip Error:'Module' Object Has No Attribute 'Cryptography_Has_Ssl_St'
Can You Fool Isatty and Log Stdout and Stderr Separately
/Usr/Bin/Ld: Cannot Find -Lpython2.7
Anaconda: Disable Prompt Change
Find Broken Symlinks with Python
Cannot Bind Numpad Minus Key on Linux with Tkinter
"Valueerror: _Type_ 'V' Not Supported" Error After Installing Pyreadline
Using && in Subprocess.Popen for Command Chaining
How to Programmatically Edit Excel Sheets
Bash: Variable in Single Quote
Running Python Script as a Systemd Service
/Usr/Bin/Env: Python2: No Such File or Directory
Python Linux Selenium: Chrome Not Reachable
Set the Hardware Clock in Python
How to Install Lxml for Python Without Administative Rights on Linux
A Way to "Listen" for Changes to a File System from Python on Linux
How to Integrate Ajax With Django Applications
What Is a Clean "Pythonic" Way to Implement Multiple Constructors