1

there! I'm new to Python (as of yesterday, when I bought a book on it called Python Crash Course (2nd ed.)). I'm having trouble getting started with the Python terminal in that I want to run my hello_world.py program from it, but can't find the darn thing from within the terminal. I'm running Windows 10. I've tried putting the directory in the root (C:) directory, on my Desktop, in my OneDrive directory, and under my name in Users and still can't navigate to it in the python terminal.

When I go to the command prompt and type "python", I get the following:

C:\Users\Anne>python
Python 3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 21:26:53) [MSC v.1916 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>

The book says to put the working folder "somewhere on your system", which is why I have tried so many locations. The working folder is currently called pywk and is located at C:\Users\Anne\pywk. Here's what I get when I try to change the directory using the cd command in the terminal:

>>> cd C:\Users\Anne\pywk
  File "<stdin>", line 1
    cd C:\Users\Anne\pywk
       ^
SyntaxError: invalid syntax
>>> cd Users\Anne\pywk
  File "<stdin>", line 1
cd Users\Anne\pywk
           ^
    SyntaxError: invalid syntax

>>> cd Anne\pywk
  File "<stdin>", line 1
    cd Anne\pywk
          ^
SyntaxError: invalid syntax
>>> cd pywk
  File "<stdin>", line 1
    cd pywk
          ^
SyntaxError: invalid syntax
>>>  

My guess is that the carat indicates where the syntax problems lie, but I don't know for sure. And I don't know what else to try or have anyone else to ask.

I'm not trying to make a program to do this (yet). I'm just trying to get to where I can run my little programs from the terminal. That way I can learn.

Thank you to anyone who can help me over this hump.

shaik moeed
  • 5,300
  • 1
  • 18
  • 54
aritchie
  • 11
  • 1
  • The Python interactive interpreter is not a shell (nor a terminal, which is the device that shows you the text UI of a computer, these days usually another window in your GUI desktop). So it won't take shell commands like `cd`. – Martijn Pieters Jul 05 '19 at 16:22
  • You have to run `cd C:\Users\Anne\pywk` before running `python` command. – Asnim P Ansari Jul 05 '19 at 16:24
  • https://stackoverflow.com/questions/431684/how-do-i-change-directory-cd-in-python – edtheprogrammerguy Jul 05 '19 at 16:24
  • Thank y'all very much. I get it, now. I really appreciate you taking a moment to help a noob. I'll be back soon to answer questions for other newbies. Thanks again. – aritchie Jul 06 '19 at 17:46

0 Answers0