TransWikia.com

Getting Tkinter to work in PyCharm using OSGeo4W64's Python

Geographic Information Systems Asked on January 24, 2021

I am creating an external QGIS program that builds virtual rasters using the processing algorithm within QGIS. I have this working, but it is not very convenient since you need to type in each file name. I would like to create a file dialog box using Tkinter.

In PyCharm the code is colored like the import is working, but then once I run the code I get an error stating that I do not have the module _tkinter. I look in the Python library in my OSGeo directory and I see a folder called tkinter.

I went to the OSGeo Shell and created a python environment in which I tired importing tkinter and got this…

>>> import tkinter
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:OSGEO4~1appsPython37libtkinter__init__.py", line 36, in <module>
    import _tkinter # If this fails your Python may not be configured for Tk
ModuleNotFoundError: No module named '_tkinter'

Any ideas as to what is happening? Would installing pip and then installing tkinter through that work? I am not quite sure how to do that in OSGeo and fear messing something up so I have not tried.

If not, does anyone know of any alternative solution for my problem?

One Answer

I just solved this for myself. Re-start the OSgeo4W installer and then do an advanced install. Search for all packages tk something and you will notice one not installed. Complete the install and try again. This fixed it for me.

Answered by user3178147 on January 24, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP