-2

Im teaching myself python and have downloaded the newest version of python 2 and also notepad++.

I have this script in notepad++ saved as Enter_your_name.py

#Program that Welcomes user ask='Enter your name:' raw_input(ask) 

When I go to the python interpreter and issue the command

python Enter_your_name.py 

I get a syntax error.

Is this because I am not in the correct directory?

Edit

>>>python Enter_your_name.py File "(stdin)", line 1 python Enter_your_name.py ^ SyntaxError: invalid syntax >>> 
4
  • 1
    FYI get rid of the semi-colons, they are not needed in Python. As far as your syntax error, please edit your post to include the full error and traceback. Commented Feb 8, 2015 at 20:39
  • You invoke the script via the command line not the interpreter. Commented Feb 8, 2015 at 20:39
  • possible duplicate of How to run a python script from IDLE interactive shell? Commented Feb 8, 2015 at 20:43
  • Thanks for the reference, I tried finding a similar question but couldnt. Maybe Im still a bit new to the site. I had to use execfile('helloworld.py') with the full path name. Commented Feb 8, 2015 at 20:50

1 Answer 1

1

Open a Command Prompt or Terminal in the current directory, then type:

python Enter_your_name.py 

Otherwise there is an option to run the program directly from IDLE in the drop down menus. Problem is you're getting a syntax error rather than a file not found error. This indicates your mistake in trying to execute a command from the Python shell.

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

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.