Hi I am working on IMX8mq evaluation kit. The tkinter module import fails in imx
>>> import tkinter
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.7/tkinter/__init__.py", line 36, in <module>
import _tkinter # If this fails your Python may not be configured for Tk
ModuleNotFoundError: No module named '_tkinter'
The yocto project version is 3.0 zeus.
distro = fsl-imx-xwayland
python3-tkinter is already in the image.
How can I resolve this ?
I had the same problem,and finally I solved it.
I referred to the following,
<Re: [yocto] Enabling tk for Python tkinter module (mail-archive.com)>
And I added
PACKAGECONFIG:append:pn-python3 = “ tk”
to my local.conf file.
After that,I had the error,
[_tkinter.TclError: no display name and no $DISPLAY environment variable]
so I add following, to my python script,and I can display my GUI.
---
if os.environ.get('DISPLAY','') == '':
print('no display found. Using :0.0')
os.environ.__setitem__('DISPLAY', ':0.0')
---
The Tkinter library is built-in with every Python installation.
The most probably you are typing the command wrong. It should be:
import Tkinter as tk
Note the capital T at the beginning of Tkinter.
For Python 3,
import tkinter as tk
Hello nishita_a,
The reason is that tk is not in oe-core (even though tcl is), so the _tkinter python extension (compiled c code) is disabled.[1]
http://layers.openembedded.org/layerindex/branch/master/recipes/?q=tkinter
Regards
Hi,
Thank you for the quick reply.
So is there any way to enable _tkinter extension?
The link provides directs to blank page in openembedded site.
Hello,
I have the same problem.
Has someone a solution?
How can I fix this problem.