By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,965 Members | 1,962 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,965 IT Pros & Developers. It's quick & easy.

SyntaxError: invalid syntax

P: n/a
I am learning Python, and i get an error in following:

i already create a module in following:

def print_func(par):
print par

then, i open new window of Python, and type import commands:
and just occur errors:

>>> import

Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
File "C:\Python27\lib\", line 1
Python 2.7 (r27:82525, Jul 4 2010, 09:01:59) [MSC v.1500 32 bit (Intel)] on win32
SyntaxError: invalid syntax
the question is what error, how i can fix it?
Oct 4 '10 #1
Share this Question
Share on Google+
2 Replies

Expert Mod 2.5K+
P: 2,851
The import statement should look like this:import hello. If you include the extension, python will try to find a module named "py".

Apparently on line 1 you have the string "Python 2.7 (r27:82525, Jul 4 2010, 09:01:59) [MSC v.1500 32 bit (Intel)] on win32". Remove that string or comment it out and try again.
Oct 4 '10 #2

Expert 100+
P: 624
Info on the shebang (first line) and import.
Oct 6 '10 #3

Post your reply

Sign in to post your reply or Sign up for a free account.