You are not logged in.

#1 2017-03-26 19:58:43

AeonSiraus
Member
Registered: 2017-03-26
Posts: 3

[SOLVED] Python tkinter not working

I already ran

$ sudo pacman -S tk

and

import tkinter as tk

works perfectly in python.

But after coding a plot, no output is created.

$ pip install tkinter

returns

Collecting tkinter
  Could not find a version that satisfies the requirement tkinter (from versions: )
No matching distribution found for tkinter

How can I get tkinter working?

Last edited by AeonSiraus (2017-03-26 21:14:39)

Offline

#2 2017-03-26 20:06:47

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,456
Website

Re: [SOLVED] Python tkinter not working

It would help if you described the actual problem.  You've described how you've installed tk - attempting both via pacman and pip.  You should use one or the other not both.  Tk in installaed via pacman, so that can be checked off the list.

So then what's the actual problem?  As you give is "after coding a plot, no output is created."  What does this mean?  Where is your code?  What kind of plot do you expect?  What output do you think should be created?


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#3 2017-03-26 20:10:41

AeonSiraus
Member
Registered: 2017-03-26
Posts: 3

Re: [SOLVED] Python tkinter not working

The code I ran was:

import matplotlib.pyplot as plt
plt.plot([1,2,3,4])
plt.ylabel('some numbers')
plt.show()

from which a graph of x=y should be generated,
but no output is geneatedn meaning no tk window opens, no error messages appear and python exits.

Last edited by AeonSiraus (2017-03-26 20:11:10)

Offline

#4 2017-03-26 20:56:04

AeonSiraus
Member
Registered: 2017-03-26
Posts: 3

Re: [SOLVED] Python tkinter not working

Update: neither tkinter nor tk were to blame. Matplotlib backend was not correct. Adding

matplotlib.use('TKagg')

solved the problem. If anyone experiences this problem or a similar one, check your backends.




Tags: Matplotlib not displaying, no output matplotlib, no plot python

Last edited by AeonSiraus (2017-03-26 21:16:37)

Offline

#5 2024-06-13 17:03:06

babaliaris
Member
From: Greece
Registered: 2017-09-29
Posts: 88
Website

Re: [SOLVED] Python tkinter not working

$ pip install tkinter

returns

Collecting tkinter
  Could not find a version that satisfies the requirement tkinter (from versions: )
No matching distribution found for tkinter

How can I get tkinter working?

For future searchers, the reason for this is because the pip python package is called tk and not tkinter, so you must do:

pip install tk

Github Account: github.com/babaliaris     big_smileArch General Guidelinesbig_smile
Favourite Distro: archlinux.org                           big_smileArch Wikibig_smile

Offline

#6 2025-03-26 22:41:20

TheGreatAndyChow
Member
Registered: 2018-05-26
Posts: 8

Re: [SOLVED] Python tkinter not working

babaliaris' answer is completely wrong. In Arch, we do not manage python using pip. You simply install python and tk:

sudo pacman -S python tk

@babaliaris, do not answer on things you don't understand. You're less than unhelpful. If a user could run your command, he'd be destroying his python installation.

Offline

#7 2025-03-26 22:50:43

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 25,081

Re: [SOLVED] Python tkinter not working

There's also no need to revive a thread that's basically from 2017 to point out that the command suggested is wrong.

Closing.

Offline

Board footer

Powered by FluxBB