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: 29,524
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

Online

#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

Board footer

Powered by FluxBB