The problem I can see here is most likely caused because you have whitespace in the script's name.

So the command line parses the name of the script up to the first word and thinks it is just Hello.

Try those two following things:

python "Hello World.py"

or

python Hello\ World.py

The quotes should "tell" the cmd that it is a single argument hence all of it is the name. Even if that doesn't work, the backslash just escapes the whitespace and that should work.

And another thing you could do is just rename the script to something like Hello_World.py - without any special symbols or whitespace.

Answer from Fanatique on Stack Exchange
🌐
Reddit
reddit.com › r/vscode › c:\python\python.exe: can't open file [errno 2] no such file or directory
r/vscode on Reddit: C:\Python\python.exe: can't open file [Errno 2] No such file or directory
March 22, 2023 - Find the directory where the file is and open VS Code in that directory. Then try to run your code. ... Check where python is located and put it in the PATH environment variable (entire folder, not one file). Also, go to r/python. That's more appropriate for your problem. ... I'm getting a {{script}} variable undefined error when executing this module within a playbook.
🌐
JetBrains
intellij-support.jetbrains.com › hc › en-us › community › posts › 11602067518226-C-Program-Files-Python311-python-exe-can-t-open-file-C-Program-Errno-2-No-such-file-or-directory
C:\Program Files\Python311\python.exe: can't open file 'C:\\Program': [Errno 2] No such file or directory – IDEs Support (IntelliJ Platform) | JetBrains
May 22, 2023 - I'm using Python 3.10 and started getting this error today. ... I created a directory junction. mklink /J C:\PyCharm "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 2022.3.2" And then run PyCharm at C:\PyCharm\bin\pycharm64.exe
Discussions

can't open file 'main.py': [Errno 2] No such file or directory
Successfully created virtual environment! Virtualenv location: C:\Users\User.virtualenvs\User-jBUq-HwN Creating a Pipfile for this project… C:\Users\User.virtualenvs\User-jBUq-HwN\Scripts\python.exe: can't open file 'main.py': [Errno 2] No such file or directory More on github.com
🌐 github.com
8
September 2, 2020
python.exe: can't open file 'generate_fingerprint.py': [Errno 2] No such file or directory Press any key to continue . . .
python.exe: can't open file 'generate_fingerprint.py': [Errno 2] No such file or directory Press any key to continue . . . More on github.com
🌐 github.com
4
June 1, 2019
Directory not found
I am getting this error: `C:\Users\Anthony.DESKTOP-ES5HL78\AppData\Local\Programs\Python\Python310\python.exe: can’t open file ‘C:\Users\Anthony.DESKTOP-ES5HL78\04_02.py’: [Errno 2] No such file or directory’ I am sure my directory is correct. What am I missing? More on discuss.python.org
🌐 discuss.python.org
10
0
March 11, 2023
android - Command Error: python.exe can't open file - Stack Overflow
I am trying the Google App Engine tutorial to make mobile assistant app using Eclipse. I am at the part where I have to try upload data to my local server. I am currently using Cygwin. However I am More on stackoverflow.com
🌐 stackoverflow.com
May 24, 2017
🌐
GitHub
github.com › Taxel › PlexTraktSync › issues › 65
can't open file 'main.py': [Errno 2] No such file or directory · Issue #65 · Taxel/PlexTraktSync
September 2, 2020 - Successfully created virtual environment! Virtualenv location: C:\Users\User.virtualenvs\User-jBUq-HwN Creating a Pipfile for this projectΓǪ C:\Users\User.virtualenvs\User-jBUq-HwN\Scripts\python.exe: can't open file 'main.py': [Errno 2] No such file or directory ·
Author: Taxel
Author: vektort13
🌐
Python.org
discuss.python.org › python help
Directory not found - Python Help - Discussions on Python.org
March 11, 2023 - I am getting this error: `C:\Users\Anthony.DESKTOP-ES5HL78\AppData\Local\Programs\Python\Python310\python.exe: can’t open file ‘C:\Users\Anthony.DESKTOP-ES5HL78\04_02.py’: [Errno 2] No such file or directory’ I am sure …
Find elsewhere
Top answer
1 of 2
1

Hello, RonanH_86

Welcome to the Microsoft Community.

Hello, thank you for your feedback here, it looks like you are having problems opening Python files.

To help you better, can you ask if the Python file you are opening is a source file or a copy sent from another source etc., in general the flashing popup window could be a file exception. I will provide you some troubleshooting suggestions for you first:

  1. Make sure Python is installed

First, make sure Python is installed on your computer.

Press Win + R, type cmd, and press Enter to open a command prompt.

Enter the following command at the command prompt:

python --version

If a version message like Python 3.x.x is returned, then Python is installed correctly. If not, go to python.org to download and install Python.

  1. Running Python from the Command Prompt

Running a Python file from the command prompt allows you to see possible error messages without having the window close quickly.

Open a command prompt:

Press Win + R, type cmd, and press Enter to open the command prompt.

Navigate to the directory where the Python files are located:

Use the cd command to enter the folder where the Python files are stored. For example, if the files are in the C:\Users\YourUsername\Downloads folder, type:

cd C:\Users\YourUsername\Downloads

Then press Enter, and the command prompt will display the current directory.

Run the Python file:

Enter the following command to run the Python file, assuming your file name is yourfile.py:

python yourfile.py

After running, if the script has errors, they will be displayed in the command prompt window and you can see the detailed error message.

  1. Adding a pause statement

If you want the window not to close automatically even if the script has no errors, you can add a pause statement to the end of the Python script. That way, when the program finishes executing, you'll be prompted to press the key to continue.

Add the following code to the end of your Python file:

input(“Press Enter to exit...”)

This line of code will cause the Python program to pause at the end and wait for you to press Enter before closing the window.

  1. File Association Settings

Sometimes the file associations on Windows systems can be incorrect, causing the .py file to close automatically when you double-click on it. You can fix the file association settings:

Right-click on the .py file and select Open as > Select another application.

In the pop-up window, select Python (if Python is not shown, click More Applications to select Python).

Check Always use this application to open .py files, and then click OK.

  1. Check for other errors

If you encounter an error when running from the command prompt, double-check the error message. There may be something wrong with the file, such as a missing library or a syntax error.

Best regards

Bobhe | Microsoft Community Support Specialist

2 of 2
0

Hi Bobhe,

Thank you for your reply.

Regarding your question, I don't know if it is a source file or copy sent from another source, and I don't know how to find that out.

Regarding the troubleshooting steps:

  1. I get the message "Python was not found; run without arguments to install from the Microsoft Store, or disable this shortcut from Settings > Manage App Execution Aliases".
  2. I get the message "Python was not found; run without arguments to install from the Microsoft Store, or disable this shortcut from Settings > Manage App Execution Aliases."

However, I have confirmed that I have correctly downloaded and installed Python 3.13.1-amd64.

I have not yet proceeded to the subsequent steps.

Thank you,

Ronan

🌐
Quora
quora.com › Why-cant-my-file-be-opened-in-Python
Why can't my file be opened in Python? - Quora
Answer (1 of 2): When I try to open my file in jupyter notebook, for some reason it says that there is no such file available. I tried using absolute paths and the output shows that the file does indeed exist on my computer, and can be found as well. But when using that absolute path to open it, ...
🌐
Python.org
discuss.python.org › python help
Can't Install Python because Executable won't Open - Python Help - Discussions on Python.org
January 5, 2023 - Hello everyone, my name is Luiz and I’m new to this forum, so please forgive me if I’m making some mistake on posting this or anything else. I wanted to learn programing for a long time and decided to start with Python, but I’m having trouble trying to install it on my computer for at least 3 hours now.
🌐
MadeForTrade
madefortrade.in › markets discussions
Python.exe: can't open file - Markets Discussions - MadeForTrade
February 16, 2024 - PS C:\Users\DEC> & “C:/Program Files/Python312/python.exe” Untitled-1 C:\Program Files\Python312\python.exe: can’t open file ‘C:\Users\DEC\Untitled-1’: [Errno 2] No such file or directory PS C:\Users\DEC>
🌐
Python Forum
python-forum.io › thread-2092.html
can't run .exe file
Hey! I have compiled my python file with pyinstaller and produced a .exe file, however my program doesn't want to run. I ran it through the shell and it printed out the following error message: Error:Traceback (most recent call last): File 'si...
🌐
YouTube
youtube.com › amjad achyq
How to fix : " Can't open file 'file.py': [Errno 2] No such file or directory " in PyCharm. - YouTube
In this video, I will show you how to fix : " Can't open file 'file.py': [Errno 2] No such file or directory " in PyCharm 2022.Buy me a coffee : https://payp...
Published: April 6, 2022
Views: 62K
🌐
CodeWithHarry
codewithharry.com › blogpost › solving-python-error-errno-2-no-such-file-or-directory
[Solved] FileNotFoundError: [Errno 2] No such file or directory: 'harry.png' | Blog | CodeWithHarry
If you encounter this error while trying to execute a Python script, make sure the script's path is correct. python my_script.py # Make sure that 'my_script.py' exists in the current directory · You can also prevent this error by utilizing the os.path module in Python to check if the file ...
🌐
JetBrains
youtrack.jetbrains.com › issue › PY-73003 › cant-open-file-CProgram-Errno-2-No-such-file-or-directory-after-a-clean-install-of-PyCharm-2024.1.2
[Errno 2] No such file or directory after a clean install ...
Our website uses some cookies and records your IP address for the purposes of accessibility, security, and managing your access to the telecommunication network. You can disable data collection and cookies by changing your browser settings, but it may affect how this website functions.
🌐
YouTube
youtube.com › watch
can't open file 'manage.py': [Errno 2] No such file or directory| SOLVED - YouTube
can't open file 'manage.py': [Errno 2] No such file or directory found error in Django python framework
Published: December 24, 2019