1

I am trying to run a script with IDLE in Python version 3.9.5. When I have IDLE open and I open the script with File > Open... it successfully opens the script. Likewise, when running IDLE3.9 from the terminal, I can successfully open the file. However, when I double-click on the .py file within my Finder, I get the following error message:

The document “hello.py” could not be opened. IDLE cannot open files in the “Python Script” format.

Here is an image of the error message:

Error message when double-clicking a .py file with IDLE set as the default application

I have seen this post on the site already, but there doesn't seem to have been a solution. When I right-click on the script and go to Get Info, the application listed under Open With is indeed listed as IDLE, and I ensured that it is the correct version of IDLE as well. Any ideas as to how I can open this or any script in general from my desktop/finder?

I am running macOS Big Sur, version 11.2.3 (20D91), on an M1 Macbook if that helps at all.

Update

So I've started a completely blank slate; I've uninstalled cond and all versions of python (except the base version all macs come with). Using anaconda, I made two new environments, one using Python 2.7.18 and one using Python 3.9.5. However, conda does not provide IDLE upon installation of various versions of python, so I installed the same versions (2.7.18 and 3.9.5) straight from the official website. Naturally, these gave me the two versions of IDLE that I needed. However, the problem seems to still persist.

The install of each version also comes with a python launcher. However, when these are used to launch the .py files, nothing happens except for this window opening:

The window that opens when using Python Launcher to open a .py file

Update 2

Interestingly enough, although double-clicking on .py files to try and open them with IDLE (Python version 3.9.5) still does not work, it actually DOES work when using the 2.7.18 Python version of IDLE instead. Perhaps I'm missing a $PATH variable that I should have added for Python 3.9.5? Not sure why 2.7.18 would work seamlessly but 3.9.5 would not.

3
  • 1
    How did you get IDLE to show up in the Open With menu? I have IDLE for Python 2 and 3, and neither shows up in that menu, which I thought only showed Finder-level Mac apps, not Terminal-only apps like IDLE. There is a Finder-level app for Python in my homebrew install (/opt/homebrew/Cellar/[email protected]/3.9.5/Frameworks/Python.framework/Versions/3.9/Resources/Python.app), which is used when IDLE launches, but I can't pass Finder files to that app with Open-With.
    – jimtut
    Commented Jun 7, 2021 at 15:46
  • @jimtut I'm not entirely sure what you mean? I've edited my post above to clarify my downloads of various IDLE versions. Here are the locations of both IDLE applications in my finder: /Applications/Python 2.7/IDLE.app along with /Applications/Python 3.9/IDLE.app
    – nliberman
    Commented Jun 8, 2021 at 8:41
  • I'm using a different install of Python (through homebrew), don't want yet-another Python install on the Mac, so I can't try out your config. Sounds like you are a programmer. My best recommendation would be write a rock-solid shell script for launching IDLE with one or more command-line arguments (PY scripts). Then, convert that script to a "real" app using Platypus. I have a few drag-and-drop apps I've created using Platypus, so it will definitely work as an IDLE launcher. You can also tag the app as being able to handle certain file types like PY, so open-with should work.
    – jimtut
    Commented Jun 8, 2021 at 13:57

1 Answer 1

0

Its because of the version issue. Download the file from he first page without looking for different versions.

image

1
  • 1
    Could you please specify in your answer what exactly is "the version issue"? It'd also be a nice touch to put in the actual download link instead of a screenshot of it. Please don't respond in a comment, update your answer instead. For future reference I'd suggest you check how the community guidelines (in Help section) define a good answer. Please remember that low-quality answers like this can lead to an answer ban. Commented Sep 26, 2021 at 13:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .