0

I am trying to run a program that I coded in the Python-IDLE in the command prompt of windows. So I watched a video on Youtube which showed me that, but it did not work. From the video I learned how to run IDLE code using a batch file. So I created a batch file in the Python IDLE and put it in the same folder in which I put the program I created with the Python IDLE. Then I used the windows (Run) command to run the batch file and the command prompt gave me an error message.

I have already tried not using the windows run command, (Win+R), but searching the command prompt in the windows search bar and then running the program which I created in the Python_IDLE in the Command Prompt, and that gave me the exact same error message.

This is the program I tried to run:

name = input('Input your name: ')
age = input('Input your birth year: ')
print(f'Hello {name}, I know you are {age} years old')

This is the error message I got (in the command prompt):

no such file or directory

This is what I wrote in the Python-IDLE to create the batch file:

@py C:\Users\Angelo Hoft\PyProjects\Greeting.py %*
@pause 

And this is the command I entered in the windows (Run) tab:

C:\Users\Angelo Hoft\PyProjects\hello.bat

Angelo Hoft is the user of the computer I am using, PyProjects is the folder in which I stored the batch file and the Python-IDLE Program I am trying to run in the command prompt

But I just want my program to ask the user for input and then make a sentence out of it which contains the user's name and age.

3
  • 1
    It would certainly help matters were you to show use the content of the batch-file, the command you entered in the run box, and/or the Command Prompt window. Commented Aug 1, 2019 at 22:12
  • I updated it. I hope this helps you in answering my question @Compo Commented Aug 1, 2019 at 23:15
  • There is no such thing as 'IDLE code'. The code you wrote with the IDLE editor is pure Python, and once you saved it, it is irrelevant what editor you used to write it. So the question is about Python on Windows, not about IDLE. no such file or directory comes from the Windows command processor, not python. User 'magoo' addressed that. Commented Aug 2, 2019 at 16:26

1 Answer 1

2

Use "C:\Users\Angelo Hoft\PyProjects\hello.bat" as your command. Since the command contains a space, cmd will interpret the command you entered as C:\Users\Angelo with an argument of Hoft\PyProjects\hello.bat. Since C:\Users\Angelo is not an executable file, cmd duly reports this. Quoting the command tells cmd that the space is part of the string, not a separator between strings.

Sign up to request clarification or add additional context in comments.

3 Comments

Thank you for answering my question @Magoo . But how do i fix that problem now
The problem appeared to be no such file or directory when running hello.bat. Perhaps changing @py C:\Users\Angelo Hoft\PyProjects\Greeting.py %* to @py "C:\Users\Angelo Hoft\PyProjects\Greeting.py" %* may cure the other problem.
It actually worked!! Many thanks for the pro called @Magoo for helping me out.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.