-1

I have pycharm installed and do my class assignment in it and things work well. The teacher wants on to now run some of the programs in command prompt. Given that my programs and the path is here: "C:\Python27\python.exe C:/Users/sz5062/PycharmProjects/untitled1/main.py", how can I run a program that is saved the above path in command line? So, example, how would I run the main.py in command line, not shell prompt?

I have searched and searched for answers here, but I can't fine one. Thanks very much for your help.

This is the full instruction: Install Python and a programming text editor and write a program that prints one line other than 'hello world', then take two screen shots and upload them below. You should use the command line to execute the Python program you wrote in the text editor. Please do not use the IDLE Python Shell, the Python Interpreter (>>>), or a shortcut in your text editor to run the code.

When i run "python main.py", I get an error message "python is not recognized as inernal or external command".

1
  • What happens when you run C:\Python27\python.exe C:/Users/sz5062/PycharmProjects/untitled1/main.py in your command line? Commented Apr 6, 2016 at 18:58

3 Answers 3

2

On you Commandline enter:

C:\Python27\python.exe C:\Users\sz5062\PycharmProjects\untitled1\main.py

The above command should work from every directory. First part is the program you start (python.exe). Second part is the argument you pass to the program(C:\Users\sz5062\PycharmProjects\untitled1\main.py). This is the path to your python code so that python.exe knows what you want to execute.

If you add C:\Python27\ to your PATH variable, you can navigate to your directory C:\Users\sz5062\PycharmProjects\untitled1\ and start your programm with:

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

1 Comment

Stimulant, is C:\Python27\ not on my ccomand already as shown above?
0

I'd recommend making sure that python is on your PATH (if you type python does it open a shell?) and then navigate to the C:/Users/sz5062/PycharmProjects/untitled1 directory. Once there you can do:

python main.py

and that should work.

1 Comment

this is the full class instruction. Please, keep in mind that I have my program working in pycharm. The concern is how to run my programs in command line as in this instruction. The concern is in quotes below. Install Python and a programming text editor and write a program that prints one line other than 'hello world', then take two screen shots and upload them below. You should use the command line to execute the Python program you wrote in the text editor. "Please do not use the IDLE Python Shell, the Python Interpreter (>>>), or a shortcut in your text editor to run the code."
0

I think I made this hard. since python was in installed on C:\python27, all I needed to run the command line was simply to write the code in a text editor, save it in the same directory and call it from there. So, essentially, c:\python27\code.py

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.