Home > Articles > Open Source > Python

  • Print
  • + Share This
This chapter is from the book

Common Student Questions

These are actual questions by real students in the comments section of the book when it was online. You may run into some of these, so I’ve collected and answered them for you.

Can I use IDLE?

No, you should use Terminal on OSX and PowerShell on Windows, just like I have here. If you don’t know how to use those, then you can go read the Command Line Crash Course in the appendix.

How do you get colors in your editor?

Save your file first as a .py file, such as ex1.py. Then you’ll have color when you type.

I get SyntaxError: invalid syntax when I run ex1.py.

You are probably trying to run Python, then trying to type Python again. Close your Terminal, start it again, and right away type only python ex1.py.

I get can't open file 'ex1.py': [Errno 2] No such file or directory.

You need to be in the same directory as the file you created. Make sure you use the cd command to go there first. For example, if you saved your file in lpthw/ex1.py, then you would do cd lpthw/ before trying to run python ex1.py. If you don’t know what any of that means, then go through the Command Line Crash Course (CLI-CC) mentioned in the first question.

How do I get my country’s language characters into my file?

Make sure you type this at the top of your file: # -*- coding: utf-8 -*-.

My file doesn’t run; I just get the prompt back with no output.

You most likely took the previous code literally and thought that print "Hello World!" meant to literally print just "Hello World!" into the file, without the print. Your file has to be exactly like mine in the previous code and all the screenshots; I have print "Hello World!" and print before every line. Make sure your code is like mine and it should work.

  • + Share This
  • 🔖 Save To Your Account