ModuleNotFoundError: No module named '_tkinter'

Hi everyone,

I am trying to use matplotlib and the Tkinter backend to visualise lidar data on a 2D cartesian graph.
However I am running into the issue:

import _tkinter # If this fails your Python may not be configured for Tk
ModuleNotFoundError: No module named '_tkinter'

I have installed tkinter onto my machine I am pretty sure but am still getting this issue. Would anyone have pointers on how to fix this? Thank you.

Hi,

did you install tkinter into your Isaac Sim python environment?

Here is the documentration for that: Python Environment Installation — Omniverse IsaacSim latest documentation (nvidia.com)

Hi @j.t

Here you can find some steps to install and use some of the matploltib backends

  • TkAgg

    Install:

    sudo apt-get install python3-tk
    

    Matplotlib configuration:

    # to get the _tkinter path run the following command in a terminal:
    #   python3.10 -c "import _tkinter; print(_tkinter.__file__)"
    # and append the parent folder to sys.path
    import sys
    sys.path.append("/usr/lib/python3.10/lib-dynload")
    
    import matplotlib
    matplotlib.use("TkAgg")
    
  • GTK4Agg / GTK4Cairo

    Install:

    sudo apt-get install libcairo2-dev libgirepository1.0-dev
    ./python.sh -m pip install --upgrade pip
    ./python.sh -m pip install pycairo PyGObject
    

    Matplotlib configuration:

    import matplotlib
    matplotlib.use("GTK4Agg")  # or GTK4Cairo
    

Hi!

Thank you for your help. However, I am still getting this error:

ImportError: /usr/lib/python2.7/lib-dynload/_tkinter.so: undefined symbol: Py_Py3kWarningFlag

Hi @j.t

Your log shows a version for Python2.7. Make sure you are installing the version for Python 3.10 (current Kit Python version is 3.10).

Hi Toni,

I am running Isaac Sim on a ubuntu machine. Does the sim use its own python environment or the python installed onto the machine?

Thank you,
Jeff

Hi @j.t

All Omniverse applications, including Issac Sim, have their own Python environment (located in the kit/python folder). You can read more about it in the following link: Python Environment Installation — Omniverse IsaacSim latest documentation

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.