Меню Рубрики

Установка tkinter python 3 windows

Need tkinter on my python 3.6 installation (Windows 10)

I’m running Python 3.6 on a Windows 10 machine. I want to display a simple matplotlib plot like this:

Unfortunately, I get the error:

I try installing tkinter through my terminal:

I also tried pip install python3-tk but without success. I found a couple of posts on StackOverflow explaining how to install tkinter properly, but they’re all about Python 2 and/or Linux systems. I couldn’t find a post particularly for Python 3.6 on Windows 10.

3 Answers 3

I got it working now. I removed my Python 3.6.1 installation and installed Python 3.6.3 from here:

I selected the Windows x86-64 executable installer for my Windows 10 computer. While installing, I chose for «custom installation» so I can check which modules I want or don’t want. Apparently, tkinter is present by default. Perhaps I had unchecked it on my last installation (a couple of months ago)?

Anyway, I got things working now. But it seems still a bit odd to me that I had to do a complete reinstallation for this to work. A simple pip install tkinter should also do the job (in my opinion).

Not sure about windows but in Ubuntu you could do sudo apt-get install python3-tk

For windows you can try import matplotlib matplotlib.use(‘agg’) import matplotlib.pyplot as plt

if you dont want to use tkinter at all. (Tested in Ubuntu)

Also dont forget to use %matplotlib inline at the top of your notebook if using one.

OK that is weird it worked like that, I had to re-install before and actually downgrade for it to work and uninstall on windows and have issues on linux also. I’ve done pip for both and everything else. Windows got it working from downgrading from 3.7 to 3.6 and uninstalling 3.7. So that may help someone.

Источник

How to install Tkinter?

How the hell to install tkinter on to my PC ?
I tried for week to install it. I can not figure it out. Please, Help.
How does it work ? Is there a site you install it from or what ?

4 Answers 4

Should be there already man.

For Linux with aptitude :

If you’re using Python 3 then you must install as follows (writing in a terminal):

Tkinter for Python 2 ( python-tk ) is different from Python 3 ‘s ( python3-tk ).

I assume you’re using Windows. If so.

Step 1. Ignore the people who say to import tkinter as tk or «It should already be there».

You’re not the only person to have this problem despite apparently every post on the Internet telling you one of those two (utterly unproductive) statements. *deep breath*

Step 2. Understand what you’re trying to do.

You’re trying to do two things. The first is to install the Tk GUI toolkit, also known as Tcl/Tk . This is a collection of software that exists independently of Python which allows for GUI development. The second is to have Python interact with Tcl/Tk . This is done with the tkinter module which allows you to call Tcl/Tk using Python.

The Python installer, by default, installs Tcl/Tk along with tkinter . The tkinter module is part of the standard library. Because tkinter is not useful without Tcl/Tk also installed, someone, somewhere, at some time, decided it wasn’t worth packaging tkinter separately. I don’t know why.

Maybe you didn’t install Tcl/Tk and tkinter when Python installed. Maybe you decided to use a different GUI framework. Maybe you thought «Why should I install something that I’ll never use, along with an IDE I’ll never use.» Maybe you later found out that a third-party library like seaborn requires it. *deep breath*

Step 3. Figure out how you want to accomplish the two things you’re trying to do.

You have two options:

Option 1. Install Tcl/Tk manually. Then maybe you can find some saint who has packaged tkinter for you. But maybe the versioning isn’t correct. So you could compile it from source and/or learn a lot about how Python packaging works.

Option 2. Rerun the Python installer. Select «Modify». Make sure that the » tcl/tk and IDLE » checkbox is ticked and press «Next» a bunch.

If all else fails, burn everything down and start from scratch. But hopefully the second option works for you like it did for me. 🙂

Источник

Install tkinter for Python

I am trying to import Tkinter . However, I get an error stating that Tkinter has not been installed:

I could probably install it using synaptic manager (can I?), however, I would have to install it on every machine I program on. Would it be possible to add the Tkinter library into my workspace and reference it from there?

18.04). 0 upgraded, 0 newly installed, 0 to remove and 19 not upgraded. – Shravya Boggarapu Sep 14 at 6:46

20 Answers 20

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.)

Actually, you just need to use the following to install the tkinter for python3:

In addition, for Fedora users, use the following command:

If, like me, you don’t have root privileges on your network because of your wonderful friends in I.S., and you are working in a local install you may have some problems with the above approaches.

I spent ages on Google — but in the end, it’s easy.

Download the tcl and tk from http://www.tcl.tk/software/tcltk/download.html and install them locally too.

To install locally on Linux (I did it to my home directory), extract the .tar.gz files for tcl and tk. Then open up the readme files inside the ./unix directory. I ran

It may seem a pain, but the files are tiny and installation is very fast.

Then re-run python setup.py build and python setup.py install in your python installation directory — and it should work. It worked for me — and I can now import Tkinter etc to my heart’s content — yipidy-yay. An entire afternoon spent on this — hope this note saves others from the pain.

-type f -name setup.py command from anywhere your shell. – Acsor Jun 25 ’17 at 14:11

If you are using Python 3 it might be because you are typing Tkinter not tkinter

For Arch Linux users, it goes a bit like

you will need the package and its dependencies.

since you mentioned synaptic, you must be using a Debian based system. one way to get what you need:

You don’t need to download Tkinter — it’s an integral part of all Python distributions (except binary distributions for platforms that don’t support Tcl/Tk).

In my case, on Windows, what helped was reinstalling the Python distribution. A long time ago, I had unchecked the «Tcl/Tk» installation feature. After reinstalling, all works fine and I can import _tkinter and import Tkinter .

If you’re using RHEL, CentOS, Oracle Linux, etc. You can use yum to install tkinter module

tk-devel also needs to be installed in my case

install these and rebuild python

for python3 user, install python3-tk package by following command sudo apt-get install python3-tk

If you’re using Python 3 then you must install as follows:

Tkinter for Python 2 ( python-tk ) is different from Python 3 ‘s ( python3-tk ).

Fedora release 25 (Twenty Five)

This worked for me.

For python 3.7 on ubuntu I had to use sudo apt-get install python3.7-tk to make it work

There is _tkinter and Tkinter — both work on Py 3.x But to be safe- Download Loopy and change your python root directory(if you’re using an IDE like PyCharms) to Loopy’s installation directory. You’ll get this library and many more.

Tkinter is a GUI module for python. you can use it to make GUI based applications in python. Tkinter provides several GUI widgets like buttons,menu, canvas,text,frame,label etc. to develop desktop applications.Though Tkinter is very popular and is included with windows, macosx install of python, There are also alternative choices like pyQt, wxPython.

In this tutorial we will see how to install it on linux and use it with an example.

First, check if you have python installed and also check its version

Open up your terminal and type python. if its installed then it will show information like version, help. check your version (mine is python 2.7.9)

$ python Python 2.7.9 (default, Apr 2 2015, 15:33:21) [GCC 4.9.2] on linux2 Type «help», «copyright», «credits» or «license» for more information.

If you don’t have python then install it sudo apt-get install python

If you want to install python 3 then enter the following. If you are a newbie, I would recommend python 2 instead of python 3. Python 2 is still very popular and many apps are made on it. On ubuntu python2 is still the default sudo apt-get install python3

Finally, Install Tkinter

Now, lets check if Tkinter is working well with this little example

open your terminal and enter into your python shell. python

for python3 python3

if python was installed correctly you will get a >>> prompt. aman@vostro:

Now import Tkinter module. it wont show any error if it got imported correctly. NOTE: Make sure you type Tkinter (not tkinter) in python2 and tkinter (not Tkinter) in python3.

Now, just to check you can create an empty window using Tkinter.

Источник

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *

  • Установка tis 2000 на windows 7
  • Установка tia portal v14 на windows 10
  • Установка tia portal v13 на windows 7
  • Установка the dude на windows
  • Установка the bat на windows 10