Exception in “Hello World” program on a clean Python installs

Asked By 0 points N/A Posted on -


I just made a clean install on Python and this exception appears in Hello World. I didn’t expect to have any error with this clean install. What creates this error? What should I do to avoid these errors that I cannot solve ?

Thank you !


‘mbcs’ codec can’t encode characters in position0—1: invalid character

Answered By 590495 points N/A #179466

Exception in “Hello World” program on a clean Python installs


I don’t think the problem is with your Python because if you’ll look at the dialog box, it says syntax error. Syntax error means incorrect usage of the command. Since the error appeared in the command “print (“HelloWorld”)”, I guess the problem here is in the usage of the open and close parenthesis.

Normally, when using the print command in Python, the texts to be displayed is not enclosed inside a parenthesis. Here, you need to remove the open and close parenthesis to properly execute the command and print HelloWorld on the screen. So, the correct command would be: print “HelloWorld”. Here is an example on using the print command:

  • import os
  • f = os.popen('date')
  • now = f.read()
  • print "Today is ", now

This example executes the date command using “os.popen()” and the output is stored in the variable called “now”. The output in this example would be:

  • Today is Tue Aug 26 00:49:23 IST 2014

Related Questions