To do so, type the following line and then hit Enter: cd "C:\Users\\Desktop" Navigate to the Desktop (where we saved the Python script). To do so, type the following line and then hit Enter: python first_script.py For example, on my computer, I’d type: cd "C:\Users\Clinton\Desktop"Īt this point, the prompt should look like C:\Users\\Desktop, and we are exactly where we need to be, as this is where we saved the Python script. Running a Python script in a Command Prompt window (Windows) You should see the following output printed to the Command Prompt window, as in Figure 1-5: Output #1: I'm excited to learn Python.įigure 1-5. When the window opens, the prompt will be in a particular folder, also known as a directory (e.g., /Users/clinton or /Users/clinton/Documents). To do so, type the following line and then hit Enter: cd /Users//Desktop Navigate to the Desktop, where we saved the Python script. Replace with your computer account name, which is usually your name. For example, on my computer I’d type: cd /Users/clinton/DesktopĪt this point, the prompt should look like /Users//Desktop, and we are exactly where we need to be, as this is where we saved the Python script. The next steps are to make the script executable and then to run the script. To do so, type the following line and then hit Enter: chmod x first_script.py #Python text editor and shell in one windows#.#Python text editor and shell in one code#.
0 Comments
Leave a Reply. |