When I type “python” in the Windows command prompt, it runs without any issues. However, I’m unable to execute any “.py” files with Python. These files do work in IDLE, and I believe I have correctly set up the environment variables. However, when I try to run the files by double-clicking them or choosing “open with Python”, they don’t work. On the other hand, I’m able to run the scripts using “ctrl + b” in Sublime Text 2.

I’ve spent two days searching for a solution online, but I haven’t been able to fix the issue. I’m starting to feel like I’m not capable of fixing it myself. Can someone please help me? I have also tried dragging the files, but that method didn’t work either:

I attempted to run the files by dragging them into the Python terminal, but that method only worked in Sublime:

I was able to execute the code in Sublime by changing the file names to be compatible with Python:

I attempted to use different file names, and I found that Python works fine. I also confirmed that Python works when I type “python” into the Windows command prompt, which indicates that the path is correct:

The directory lists the file, but Python is unable to detect it, and the error message indicates that the file does not exist:

Askify Moderator Edited question May 3, 2023