marvel-nccr / ansible-role-python

Ansible role for installing a specific base python version and environment
Other
1 stars 1 forks source link

tkinter on redhat (and testing of tkinter) #5

Open chrisjsewell opened 3 years ago

chrisjsewell commented 3 years ago

for Ubunut, there is a python3.x-tk package available for 3.6-3.8 (via deadsnakes repo).

However, this is not the case for base yum in redhat:

centos8:

[root@instance ~]# yum search tkinter
Last metadata expiration check: 0:15:10 ago on Thu 26 Nov 2020 12:57:02 PM UTC.
============================================= Name Matched: tkinter ==============================================
python3-tkinter.x86_64 : A GUI toolkit for Python
python2-tkinter.x86_64 : A graphical user interface for the Python 2 scripting language
python3-tkinter.i686 : A GUI toolkit for Python
python3-tkinter.x86_64 : A GUI toolkit for Python
python38-tkinter.x86_64 : A GUI toolkit for Python

fedora31:

python3-tkinter.x86_64 : A GUI toolkit for Python
python2-tkinter.i686 : A graphical user interface for the
                     : Python 2 scripting language
python2-tkinter.x86_64 : A graphical user interface for the
                       : Python 2 scripting language
python3-tkinter.i686 : A GUI toolkit for Python
python3-tkinter.x86_64 : A GUI toolkit for Python

Current;y I a'm "falling back" to just install python3-tkinter if python3x-tkinter fails, but I don't know if that will actually work.

Ideally we would also test that tkinter is working on all distributions. This is tricky though, because really you need a display:

[root@instance ~]# python3.8
Python 3.8.0 (default, May  7 2020, 02:49:39) 
[GCC 8.3.1 20191121 (Red Hat 8.3.1-5)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tkinter
>>> tkinter._test()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib64/python3.8/tkinter/__init__.py", line 4552, in _test
    root = Tk()
  File "/usr/lib64/python3.8/tkinter/__init__.py", line 2261, in __init__
    self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
_tkinter.TclError: no display name and no $DISPLAY environment variable
chrisjsewell commented 3 years ago

Perhaps using xvfb: https://serverdiary.com/linux/how-to-install-xvfb-and-create-systemd-xvfb-service-on-centos-7-8-or-rhel-7-8/

chrisjsewell commented 3 years ago

Ah so actually on Ubuntu it is defaulting to python3-tk which installs for all python 3.6-3.8: https://stackoverflow.com/questions/59725147/install-tkinter-for-python-3-7-3-in-ubuntu-18-04

# dpkg-query -L python3-tk
/.
/usr
/usr/lib
/usr/lib/python3.6
/usr/lib/python3.6/lib-dynload
/usr/lib/python3.6/lib-dynload/_tkinter.cpython-36m-x86_64-linux-gnu.so
/usr/lib/python3.6/tkinter
/usr/lib/python3.6/tkinter/__init__.py
/usr/lib/python3.6/tkinter/__main__.py
/usr/lib/python3.6/tkinter/colorchooser.py
/usr/lib/python3.6/tkinter/commondialog.py
/usr/lib/python3.6/tkinter/constants.py
/usr/lib/python3.6/tkinter/dialog.py
/usr/lib/python3.6/tkinter/dnd.py
/usr/lib/python3.6/tkinter/filedialog.py
/usr/lib/python3.6/tkinter/font.py
/usr/lib/python3.6/tkinter/messagebox.py
/usr/lib/python3.6/tkinter/scrolledtext.py
/usr/lib/python3.6/tkinter/simpledialog.py
/usr/lib/python3.6/tkinter/tix.py
/usr/lib/python3.6/tkinter/ttk.py
/usr/lib/python3.7
/usr/lib/python3.7/lib-dynload
/usr/lib/python3.7/lib-dynload/_tkinter.cpython-37m-x86_64-linux-gnu.so
/usr/lib/python3.7/tkinter
/usr/lib/python3.7/tkinter/__init__.py
/usr/lib/python3.7/tkinter/__main__.py
/usr/lib/python3.7/tkinter/colorchooser.py
/usr/lib/python3.7/tkinter/commondialog.py
/usr/lib/python3.7/tkinter/constants.py
/usr/lib/python3.7/tkinter/dialog.py
/usr/lib/python3.7/tkinter/dnd.py
/usr/lib/python3.7/tkinter/filedialog.py
/usr/lib/python3.7/tkinter/font.py
/usr/lib/python3.7/tkinter/messagebox.py
/usr/lib/python3.7/tkinter/scrolledtext.py
/usr/lib/python3.7/tkinter/simpledialog.py
/usr/lib/python3.7/tkinter/tix.py
/usr/lib/python3.7/tkinter/ttk.py
/usr/lib/python3.8
/usr/lib/python3.8/lib-dynload
/usr/lib/python3.8/lib-dynload/_tkinter.cpython-38-x86_64-linux-gnu.so
/usr/lib/python3.8/tkinter
/usr/lib/python3.8/tkinter/__init__.py
/usr/lib/python3.8/tkinter/__main__.py
/usr/lib/python3.8/tkinter/colorchooser.py
/usr/lib/python3.8/tkinter/commondialog.py
/usr/lib/python3.8/tkinter/constants.py
/usr/lib/python3.8/tkinter/dialog.py
/usr/lib/python3.8/tkinter/dnd.py
/usr/lib/python3.8/tkinter/filedialog.py
/usr/lib/python3.8/tkinter/font.py
/usr/lib/python3.8/tkinter/messagebox.py
/usr/lib/python3.8/tkinter/scrolledtext.py
/usr/lib/python3.8/tkinter/simpledialog.py
/usr/lib/python3.8/tkinter/tix.py
/usr/lib/python3.8/tkinter/ttk.py
/usr/share
/usr/share/doc
/usr/share/doc/python3-tk
/usr/share/doc/python3-tk/README.Debian
/usr/share/doc/python3-tk/README.Tk
/usr/share/doc/python3-tk/changelog.Debian.gz
/usr/share/doc/python3-tk/copyright
/usr/share/lintian
/usr/share/lintian/overrides
/usr/share/lintian/overrides/python3-tk