Ask Your Question
1

Is there any way to import tkinter in Sage?

asked 2019-05-18 14:05:25 +0100

Taoufik ahanchaou gravatar image

updated 2020-07-26 16:27:23 +0100

slelievre gravatar image

i want to organise my work on pretty interface using tkinter module, but it seems that is not obviously easy to do bcs all time i get error becs of importation of tkinter!!! any one had already deal with this issu, can help i'll be thankful. is there any other tool to build interfaces? this is the msg that i got

  `   ImportError                               Traceback (most recent call last)
<ipython-input-5-2602f712d6ec> in <module>()
----> 1 import tkinter

/opt/sagemath-8.6/local/lib/python2.7/site-packages/tkinter/__init__.py in <module>()
      3 
      4 if sys.version_info[0] < 3:
----> 5     from Tkinter import *
      6     from Tkinter import (_cnfmerge, _default_root, _flatten, _join, _setit,
      7                          _splitdict, _stringify, _support_default_root, _test,

/opt/sagemath-8.6/local/lib/python2.7/lib-tk/Tkinter.py in <module>()
     37     # Attempt to configure Tcl/Tk without requiring PATH
     38     import FixTk
---> 39 import _tkinter # If this fails your Python may not be configured for Tk
     40 tkinter = _tkinter # b/w compat for export
     41 TclError = _tkinter.TclError

ImportError: No module named _tkinter`
edit retag flag offensive close merge delete

Comments

Some basic questions: how did you install Sage, and what OS are you using? Also, does tkinter work with your system's Python?

John Palmieri gravatar imageJohn Palmieri ( 2019-05-18 23:45:13 +0100 )edit

I installed my sage from the siteweb, and i have windows 8.1, and yeah i already use tkinter with python 3 and it works perfectly

Taoufik ahanchaou gravatar imageTaoufik ahanchaou ( 2019-05-19 21:04:46 +0100 )edit

Does sage -pip install pytk solve your problem?

dsejas gravatar imagedsejas ( 2019-05-20 19:20:48 +0100 )edit

@dsejas That won't help. The Windows version currently does not include tkinter or tcl/tk. Depending on your use case you might find it useful instead to use interactive widgets in a Jupyter notebook using interacts: http://doc.sagemath.org/html/en/prep/...

Iguananaut gravatar imageIguananaut ( 2019-05-21 15:00:26 +0100 )edit

@dsejas i actually i try it now and it seems that it may be work but i got that msg check the permission ?

Taoufik ahanchaou gravatar imageTaoufik ahanchaou ( 2019-05-22 01:28:59 +0100 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2020-07-26 16:32:18 +0100

slelievre gravatar image

The Python used by Sage may have or lack a tkinter module, depending on the platform and on how Sage was installed.

On macOS, if one installs Sage from the binaries on the Sage website, this will not be the case, but the "Topology of 3-manifolds" group provides a script to enable openssl and tkinter for an existing Sage on macOS, see

I wonder if there would be a way to similarly come up with a way to optionally enable tkinter for an existing Sage on Windows.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2019-05-18 14:05:25 +0100

Seen: 831 times

Last updated: Jul 26 '20