IDLE freezing/unresponsive when saving new file - python

I am brand new to python and programming more generally so 1) I'm an ignorant noob and I apologize and 2) I'm really just using IDLE for very basic learning. I'm running python 3.7.6 on Mac OS Catalina 10.15.3
My problem is bizarre: When I go to save a new .py file, IDLE freezes and becomes unresponsive. I'll hit CMD+S on a new/'Untitled.py' file, the save folder will pop open, and I can name the new file/navigate folders, but once I hit "Save", the program freezes with the save folder still open, except now the Save/Cancel buttons are greyed out and the entire application becomes unresponsive. My only recourse is to Force Quit and relaunch IDLE, and the new file I was trying to save never saved. You can imagine how fun this is.
What's weird is it doesn't happen every time. If I open IDLE, open a new file and very quickly/immediately save (which I try to do by default), then the file will save. Once I've saved it once, I have no problems saving the existing file as I work on it. That is, the issue is only with the creation/save of new files. I'm also not sure why sometimes I can Save a new file and other times (especially if IDLE has been open for a while) it crashes.
To be clear: I can open files, save existing files, and run programs I've written without incident. I am not getting any warnings, crash notifications, or notices of any kind that even acknowledge that IDLE is acting up.
I had 3.8, which I replaced for 3.7.6 thinking a more stable version might solve my problems, but no dice. I only have python 3.7.6 on my computer: No python 2, nothing else. I have no idea what's going on but this is super frustrating and I just want to be able to learn Python without these weird roadblocks.
Please help!

I've also had this problem, and what I did was change the location of where the file would save. I suggest trying this to help.

I'd suggest reinstalling python idle (your programs will be saved). If this doesn't work then maybe it has something to do with your security on the mac.

I had the same problem, and as Aadi suggested, I was able to fix it by changing the location of where the file was saved. Possibly, this relates to very long paths, at least in Windows 10.
The path that didn't work was 114 characters long. The path that did work was 93 characters long. The paths are the same up to character 80 and use underscore (_) but no unusual characters.

You don't have to make/save python files in IDLE. You can open any text editor, type the code, and save as name.py. Then you can open that in IDLE. I would use that for now.

I also came across with same issue, this is only issue of currupt file,please delete recent python IDLE file that you have created,this will definately work

Related

Python script closes without even running

I wrote a python script to run some simple tasks and this issue has been happening randomly at times.
Upon clicking on .py file, a cmd prompt window appears for a some microseconds and closes immediately without showing any text.
I thought this issue was because the code finished running too fast at first but the code doesnt actually run. I know this because the code involves sending a text message on discord through the requests module and I can see post-running that no text has been sent.
If it was the prior assumed issue, I would've just added some input for the program to recieve but my program has an infinite while loop in it which should be already enough to keep the cmd window open. Hence I dont understand what's causing this.
The last time it happened I somehow found a solution which I followed step by step and was able to resolve it but its happening again now and I cant find that solution again unfortunately. From vague memory, I recall the solution involved running some commands on windows terminal.
Are you double clicking the .py file? If so, it may not work in some situations. What you should do is open up your cmd and type the following.
C:\Users\Admin> python filename.py
You can replace filename with your file's name.
If you are using Mac or any Apple devices, you will need to replace python with python3.

Why do my files in vscode keep being deleted after trying to execute them?

I am currently learning to code with python in vscode but recently I have been having problems with file seemingly deleting themselves after attempted execution (image 1). I have tried Ctrl+z and I have tried recovering them but neither have worked. The files are not in my recycling bin either. If I try to create a new file of the same name in the same folder it shows me a error message (image 2) of "unable to resolve non-existing files"
When I execute my code the file saves but then becomes deleted:
This message appears if I try to undo the delete:
Have you tried to restart vscode? It is recommended that you could try the following aspects:
Check if there is any effect caused by the related expansion. For example, LaTeX Workshop extension has the function of cleaning generated files.
Check your setting.json Files,clear the contents of the user setting.json file and the vs code will return to the default value.
If it still doesn't work, you could consider installing vscode again.
Try running the Python file through a command prompt or terminal using the command python <foo_file_name>. Doing this will either confirm or deny the theory that #jasonharper made in the comments.
If you can run the script that way then we know that #jasonharper was correct and somehow your execute button/command was tampered with.
I had a similar issue using a different programming language. Building generated a file that got deleted automatically.
In my case the Windows 10 default antivirus was the cause. Turned off real-time scanning, tried again and then my files weren't deleted.
Adding an exception for the folder fixed it.
I had the Same problem with a PHP file, and turns out it wasn´t VS CODE. It was my antivirus that was moving the file to quarentine!!

Unprecedented file save issue

Couple minutes ago, I created a new python file, It did not work in Sublime(without errors, just didn't build) , so I wanted to try it in IDLE, And when I tried to save it(Ctrl-S), Here is the issue I faced.
I did not yet try to delete and recreate the file because I would like to know what would have caused such an interesting problem. The file is right there, and it cannot be saved. It is on desktop so it cannot be about security permissions.
I use 64 bit Windows 10 OS.
Edit1: When I open it with sublime or Idle, it appears as a complete blank file(Because it cannot be saved). However when I open it with notepad, the whole code is there and saved. Da hell is happening ?

Hard times with IDLE

So I've been working with Python on my computer for about the last 2 months with no issues. Just recently however, something went wrong with IDLE. I am running python 2.5
I used to be able to right-click and select "Edit with IDLE" for a python program. That option no longer is available. When I try "open with" and navigate to the idlelib in python, I can select idle.bat, idle.py, or idle.py (no console). I've tried each option and each fails to open and returns an error that either it is not a valid Win32 application or that "Windows cannot find idle.pyw"
I am able to open IDLE on its own and use the open function in IDLE to open files, but can't open files directly using IDLE as I could before.
There was formerly the White background icon with the python logo, which is now replace by windows' logo for no program (white square, blue and red dots). I have tried to repair-install and unistall-re-install both with no success. There is no firewall or antivirus, and it was installed with permissions for all users.
Any help is much appreciated, this has been maddeningly difficult to figure out.
The native one that comes with python on windows is problematic at times, so you could uninstall and reinstall it as a solution, or open it from its directory instead of a shortcut, or get another IDE. I recommend the Ninja IDE very nice and light looking, or if you're on linux you could just use vim from terminal.
Also, if it's extremely necessary, try upgrading your python version and IDE. I think the IDE included for windows looks like a modified emacs to be honest.
The fact that Windows changed the right-context menu for .py files has nothing to do with Idle, and probably nothing to do with Python either. You are not the first to have this problem. You can potentially restore 'Edit with Idle' but without directly editing the registry (an expert option) I only knew how to do so in XP. You might also be able to fix it be going back to a restore point before it changed, but you would lose all updates since, so I would not do that.
I am surprised that re-installing did not restore it. The line was once gone for me, too, and was restored by a recent install.
I have Win7. I just now tried 'Open with', navigated to 3.4 idlelib, and selected idle.bat (the .py files were not offered as a choice). The .py file opened in an Idle editor just fine. It is now a permanent option for Open with, without having to navigate.
Idle has gotten perhaps 150 patches since 2.5. Even if you have to edit programs to run on 2.5, I strongly recommend installing a current version of Python and Idle.
I have no ideal what your comment "the programs still can't find anything associated with it, like Tkinter for example " means.

Python 2.7.8 IDLE will not open on Mavericks

I installed Python 2.7.8 for a class about a week ago and I used it all week and it opened and worked. I even installed the updated ActiveTcl 8.5.15 when I heard about the IDLE crash issue. After installing ActiveTcl 8.5.15 it continued to work perfectly, but now whenever I try to open IDLE it opens for a second then crashes. After I try to open it and it crashes, the next time I try it just bounces on my dock and nothing happens. I've tried reinstalling and everything, but nothing has worked. As of now, I haven't found anyone else that has ever run into this problem.
Your afterthought comment has the answer: somehow, 'Shift' got re-written as 'shift' in one of two files. The fix is to change it back. I reproduced the error _tkinter.TclError: bad event type or keysym "shift" on Windows by editing each file. I will let you translate the file paths to osx paths.
.../python27/lib/idlelib/config-keys.def This file should not be touched after installation.
/users/Terry/.idlerc/config-keys.cfg This file is written if you edit Options / Idle preferences / Keys / Custom Key Bindings. It can also be edited by hand. It is read on startup if Use custom is checked.
One can delete any or all of the files in .idlerc and Idle will run.
I added a note about this specific report to a Python tracker issue. You are not, unfortunately, the first with a similar problem. Fixing this and similar problems is high on my priority list. I am very curious, however, which file is bad and how this happened. Did you edit key bindings either through the dialog or an editor? Or do you think something else corrupted the file?

Categories

Resources