This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: using tkinter.filedialog.askopenfilename() freezes python 3.8
Type: Stage:
Components: Tkinter Versions: Python 3.8
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: Daniel Preston, colin.caprani, gpolo, paul.moore, serhiy.storchaka, steve.dower, terry.reedy, tim.golden, zach.ware
Priority: normal Keywords:

Created on 2019-12-04 19:44 by Daniel Preston, last changed 2022-04-11 14:59 by admin.

Messages (13)
msg357819 - (view) Author: Daniel Preston (Daniel Preston) Date: 2019-12-04 19:44
I am using Tkinter in my program, and at a point I use a button to open a file by running a function with the following code:
def UploadAction(event=None):
     global filename
     filename = filedialog.askopenfilename()
     filename = [filename]
return filename
However, when I run this function, it causes Python to freeze. Apparently there have been bugs like this before in previous versions, and this wasn't a problem on 3.7, which makes me suspect that this is a bug rather than a fault on my end. Would you be able to release an update to fix this bug? Thanks.
msg357820 - (view) Author: Paul Moore (paul.moore) * (Python committer) Date: 2019-12-04 19:53
Can you provide a minimal, self-contained, example of a program that demonstrates this behaviour in 3.8, but works in 3.7. It's not really possible to determine what the issue might be without a means of reproducing the problem.
msg357822 - (view) Author: Matthew Barnett (mrabarnett) * (Python triager) Date: 2019-12-04 20:07
I've just tried it on Windows 10 with Python 3.8 64-bit and Python 3.8 32-bit without issue.
msg357823 - (view) Author: Daniel Preston (Daniel Preston) Date: 2019-12-04 20:09
Just tried to do that and found out that IDLE also crashes when opening a new python file, not just when using that code. Maybe it's a problem just with my computer? I am running python on Windows with an AMD Ryzen 5 processor with 8GB RAM if it helps.
msg357829 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2019-12-04 21:05
What is your OS? Is it macOS specific issue?
msg357830 - (view) Author: Daniel Preston (Daniel Preston) Date: 2019-12-04 21:10
No, it is an issue with Windows. I think it might only be a problem with my computer though, maybe the fact that I have an AMD processor might have something to do with the problem?
msg357832 - (view) Author: Steve Dower (steve.dower) * (Python committer) Date: 2019-12-04 21:13
Processor type is far less likely than a shell extension.

Do you have anything like DropBox/Tortoise???/etc. installed?
msg357841 - (view) Author: Daniel Preston (Daniel Preston) Date: 2019-12-05 08:33
I have dropbox installed, would that be what's causing the problem?
msg357868 - (view) Author: Steve Dower (steve.dower) * (Python committer) Date: 2019-12-05 16:58
Potentially. I don't have it installed, so I can't test, but I know in the past it added a shell extension that would display overlays over files it controlled.

That shell extension will be loaded into most system file picker dialogs, and at various points has executed Python code. I doubt they're on 3.8, but it's possible that there is some kind of conflict.

Can you try uninstalling or disabling its shell integration?
msg357870 - (view) Author: Daniel Preston (Daniel Preston) Date: 2019-12-05 17:20
How would I do that?
msg357872 - (view) Author: Steve Dower (steve.dower) * (Python committer) Date: 2019-12-05 17:28
Temporarily uninstalling your Dropbox client is the easiest way.
msg357949 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2019-12-06 22:43
filedialog.askopenfilename returns 'Open(**options).show()'.  IDLE's File => Open (^O) calls Open and show directly.  It continues to run on all versions on my machine (and presumably those of numerous others).  I have TortoiseGit now and only recently removed TortoiseHG, so those two seem well-enough behaved.  This is almost certainly not a cpython issue, but it would be good to know where the problem lies.
msg390586 - (view) Author: Colin Caprani (colin.caprani) Date: 2021-04-09 02:57
In case it helps, I have the same problem. Running python 3.8.8 on Windows 10, and any MWE doesn't work, e.g.:

from tkinter import filedialog
from tkinter import *

root = Tk()
root.filename =  filedialog.askopenfilename(initialdir = "/",title = "Select file",filetypes = (("jpeg files","*.jpg"),("all files","*.*")))
print (root.filename)

I just get the spinning circle and unresponsive dialog. I have quite a few shell integrations so uninstalling them is not ideal.
History
Date User Action Args
2022-04-11 14:59:24adminsetgithub: 83155
2021-04-09 02:57:37colin.capranisetnosy: + colin.caprani
messages: + msg390586
2019-12-06 22:43:52terry.reedysetnosy: + terry.reedy
messages: + msg357949
2019-12-05 17:28:41steve.dowersetmessages: + msg357872
2019-12-05 17:20:13Daniel Prestonsetmessages: + msg357870
2019-12-05 16:58:27steve.dowersetmessages: + msg357868
2019-12-05 08:33:17Daniel Prestonsetmessages: + msg357841
2019-12-04 21:13:10steve.dowersetmessages: + msg357832
2019-12-04 21:10:39Daniel Prestonsetmessages: + msg357830
2019-12-04 21:05:58serhiy.storchakasetmessages: + msg357829
2019-12-04 20:11:08brett.cannonsettitle: using filedialog.askopenfilename() freezes python 3.8 -> using tkinter.filedialog.askopenfilename() freezes python 3.8
2019-12-04 20:09:56Daniel Prestonsetnosy: - mrabarnett
messages: + msg357823
2019-12-04 20:07:24mrabarnettsetnosy: + mrabarnett
messages: + msg357822
2019-12-04 19:55:23paul.mooresetnosy: + gpolo, serhiy.storchaka
2019-12-04 19:53:39paul.mooresetmessages: + msg357820
components: + Tkinter, - Windows
2019-12-04 19:44:42Daniel Prestoncreate