0

Windows 10
Python 3.7.4
OSGeo4W Shell

C:\ActiveTcl\bin is in the PATH
tkinter folder is located in C:/OSGeo4W64/apps/Python37/lib/tkinter

python test_data_analysis.py
Traceback (most recent call last):
  File "test_data_analysis.py", line 4, in <module>
    from matplotlib import pyplot
  File "C:\OSGEO4~1\apps\Python37\lib\site-packages\matplotlib\pyplot.py", line 2355, in <module>
    switch_backend(rcParams["backend"])
  File "C:\OSGEO4~1\apps\Python37\lib\site-packages\matplotlib\pyplot.py", line 221, in switch_backend
    backend_mod = importlib.import_module(backend_name)
  File "C:\OSGEO4~1\apps\Python37\lib\importlib\__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "C:\OSGEO4~1\apps\Python37\lib\site-packages\matplotlib\backends\backend_tkagg.py", line 1, in <module>
    from . import _backend_tk
  File "C:\OSGEO4~1\apps\Python37\lib\site-packages\matplotlib\backends\_backend_tk.py", line 6, in <module>
    import tkinter as tk
  File "C:\OSGEO4~1\apps\Python37\lib\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'

under py3_env I have attempted importing:

  • _tkinter
  • tkinter
  • _Tkinter
  • Tkinter

importing tk works.

Oddly enough, when I run from the Python 3.7.4 shell import tkinter works, but import tk does not.

Running python -m (all tkinter varieties) does not work.

Running python -m pip install (all tkinter varieties) does not work.

I'm on the struggle bus with this one. Any suggestions that are for Windows would be great.

1 Answer 1

-1

Please download (or rerun) the Python installer for your version - in your case 3.7.4 . In the installation Menu choose to modify existing installation and in next screen select "tcl/tk' option. Proceed with the install until the end. It should work afterwords. So far its the only option to add it on Windows.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .