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 Object-Oriented Python (retired) Hack-n-Slash The Final Push

Andrew Merrick
Andrew Merrick
20,151 Points

Make Sure To Use Python3 and Not Python

I created this game on my local computer and for the life of me couldn't figure out why it did not properly run.

My default setting for Python is 2.7.1 so when I used python game.py it kept throwing errors.

I think it might be good to suggest to set your default Python to 3.5.1 or to make sure to type python3 game.py. python3 ran fine.

Not sure if any of these videos mention that...

1 Answer

It is great that you kept at it until you figured out the issue.

So it was mentioned in the intro video to this series: What are objects and classes that he would be using Python 3. Also if you follow along using Workspaces as he does in the videos, Workspaces is using Python 3. I assume you were following along locally on your machine, so these things can easily be missed as it it is not printed on every page or said in every video.

Now not all Operating Systems are built the same, I would advise against changing your OS Default for Python. Especially if you are on Mac or Linux. Mac and Linux generally come with Python 2.7+. Changing your default from 2.7(which most versions of Mac and Linux use) to the newer 3+ , you can actually break parts of your system that are reliant on that older version.

I remember I was messing around with Linux awhile back and I installed one of the newer distros of Linux. To my surprise it actually came with Python 3. So hopefully in a not so distance future most systems will have adopted Python 3.

If at any point in time you want to know if you have Python on your system and what version your python command is running. You can always type the following in your command prompt or terminal

python --version