Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python

Please recommend a Python Compiler for Mac OS to run and test my code

I've tried to use Xcode however it is not working the way I hopped it would. It will only let me print the code, however I cannot print anything in console like in Treehouse Workspaces.

6 Answers

David Bouchare
David Bouchare
9,224 Points

I personally use Sublime Text as an Editor and run my code in command line via the Mac terminal:

python nameofyourfile.py

I have both Python 2.7.5 and 3.4.1 installed on my Mac.

Don't know if that helps.

Tony Tran
Tony Tran
1,256 Points

I also use Sublime Text 2 and it allows you to use the console directly under it just like in the Treehouse Workspace.

David Bouchare
David Bouchare
9,224 Points

True. Although the console within Sublime Text 2 will execute my code with Python 2.x. Probably some configuration I need to do to switch to Python 3.x

Kenneth Love
STAFF
Kenneth Love
Treehouse Guest Teacher

Sublime Text 3 is built with Python 3, IIRC.

Thank you everyone :)

I have installed Sublime Text 2 on my Mac computer, and I it builds the code fine, however I still cannot use console (the one that build in with Sublime) neither with the Terminal. exp: with shopping_list.py code I do the following in Terminal:

94:~ admin$ python shopping_list.py python: can't open file 'shopping_list.py': [Errno 2] No such file or directory

94:~ admin$ cd /Users/admin/Documents/Python_code

94:Python_code admin$ python shopping_list.py What should we pick up at the store? Enter DONE to stop. Enter HELP for help.

HELP

Traceback (most recent call last): File "shopping_list.py", line 19, in <module> new_item = input("> ") File "<string>", line 1, in <module> NameError: name 'HELP' is not defined

94:Python_code admin$

Kenneth Love
Kenneth Love
Treehouse Guest Teacher

Looks like ST2 is using Python 2 to evaluate your code. Unfortunately, ST2 uses a built-in version of Python which is hardcoded to Python 2.6. There is a way around it, apparently but I haven't tested that myself.