Python Forum

Full Version: mx19.2 python & tkinter
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
i have python installed on mx 19.2

from xterm

bill@mx:~
$ python -V
Python 2.7.16
bill@mx:~
$ python3 -V
Python 3.7.3
bill@mx:~

bill@mx:~
$ whereis python
python: /usr/bin/python2.7 /usr/bin/python3.7 /usr/bin/python3.7m /usr/bin/python /usr/lib/python2.7 /usr/lib/python3.7 /usr/lib/python2.6 /etc/python2.7 /etc/python3.7 /etc/python /usr/local/lib/python2.7 /usr/local/lib/python3.7 /usr/include/python2.7 /usr/include/python3.7m /usr/share/python /usr/share/man/man1/python.1.gz
bill@mx:~
$

bill@mx:~
$ sudo apt install python3.7 python3-tk
Reading package lists... Done
Building dependency tree
Reading state information... Done
python3-tk is already the newest version (3.7.3-1).
python3.7 is already the newest version (3.7.3-2+deb10u2).
python3.7 set to manually installed.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
bill@mx:~

if i run a script dloaded from the net in geaney i get

import tkinter as tk
ImportError: No module named tkinter

help please
re: import tkinter as tkinter ImportError: No module named tkinter



apt list | grep python3-tk

and then



python3 -m tkinter


ie

bill@mx:~
$ apt list | grep python3-tk

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

python3-tk/oldstable,now 3.5.3-1 amd64 [installed]
python3-tk-dbg/oldstable 3.5.3-1 amd64
python3-tksnack/oldstable,oldstable 2.2.10.20090623-dfsg-6 all
bill@mx:~
$ python3 -m tkinter
bill@mx:~


why does this show tkinter to be installed yet a script that includes import tkinter etc fails?

thanks
You have multiple versions of python3

Look at the folder

/usr/lib/python3.7/

is there a tkinter folder ?
thanks Axel

i have both python 2.7 and 3.5 installed
user/lib3.5 includes tkinter but not usr/lib/python2.5

can i uninstall 2.5 to fix the problem?

thanks
No, I mean python3 only.

What is the output of

ls /usr/lib/ | grep python
thanks for the quick reply

as requested

bill@mx:~
$ ls /usr/lib/ | grep python
libpyglib-2.0-python2.7.so.0
libpyglib-2.0-python2.7.so.0.0.0
python2.6
python2.7
python3
python3.5
bill@mx:~

thanks again
ok ive managed to get 1 script dloaded from the web to run by opening a terminal and entering

python3 /path-to-file/file-name.py

but this does not work with other examples
plus i am unable to run same script from geany/idle/thonny/glade etc