-6

I need to run a Python script from the command line for a class, but I don't have a program that will allow me to do that. Normally I use repl.it, but my program requires me to type in lines from the command prompt this time around. One of my classmates recommended Atom, but I don't want to download a full package just for a single use; only what's needed to run Python 3 commands.

I did google "run python from command line" and I have looked through the first result, but how would I configure windows to allow me to execute a .py file?

2 Answers2

1

I am not sure what you are asking, a simple google search should have solved your query. Just to help, check the following:

python <filename.py>

Alternatively, type python to launch python shell and then

execfile('<filename.py>')

filename.py can be an absolute or relative path.

"but my program requires me to type in lines from the command prompt this time around"- You can enter input in repl.it also. Not sure what you mean here.

Abhishek Bhatia
  • 9,404
  • 26
  • 87
  • 142
0

Once you go to your shell interface you must enter the folder that has your python application. For example, if the folder is on the desktop then type in 'cd Desktop/' or just type the first few letters of Desktop/ and then hit 'tab' and it will enter it for you. Once you are there type python3 into the command line and the following (or some form of it) should appear: "[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin Type "help", "copyright", "credits" or "license" for more information." Once you have this click import 'python_folder_name' with your programs. Then once this is done you can use methods of your program with python_folder_name.class_name.method_or_function_name('parameters'). This should be enough to help you get started.

JohnColtraneisJC
  • 198
  • 1
  • 13