1

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

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?

1

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.

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.