[Python] Python: Tkinter askdirectory() seems to hang in VSCode

Discussão em 'Python' iniciado por Stack, Maio 22, 2025.

  1. Stack

    Stack Membro Participativo

    I'm trying to set up some Python scripts to do some file manipulation and I was trying tkinter after some googling of libraries to use.

    The following only half works:

    from tkinter import filedialog

    file_path = filedialog.askopenfilename()
    print(file_path)
    export_folder = filedialog.askdirectory()
    print(export_folder)


    When I run this code in VSCode, the askopenfilename() works properly, but when it moves on to the askdirectory() it just seems to hang and I end up having to kill the script after some time.

    However, when I run the exact same code using IDLE, it does both things just fine.

    Has anyone else had this issue with VSCode and if so, how did you fix it?

    Continue reading...

Compartilhe esta Página