import tkinter fails in IMX8

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

import tkinter fails in IMX8

2,931 Views
nishitha_a
Contributor I

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 ?

 

0 Kudos
5 Replies

2,054 Views
may_snow
Contributor I

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')
---

 

0 Kudos

2,894 Views
toanjunifer
Senior Contributor I

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

2,918 Views
Bio_TICFSL
NXP TechSupport
NXP TechSupport

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

 

0 Kudos

2,913 Views
nishitha_a
Contributor I

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.

0 Kudos

2,741 Views
sebastiansuesen
Contributor II

Hello,

I have the same problem.

Has someone a solution?

How can I fix this problem.

0 Kudos