Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Python Object-Oriented Python Advanced Objects Emulating Built-ins

Swan The Human
Swan The Human
Full Stack JavaScript Techdegree Student 19,326 Points

Getting error code play.py python: can't open file 'play.py': [Errno 2] No such file or directory

ive tried writing and rewriting the code myself multiple times and i finally broke down and just downloaded the zip and uploaded everything exactly as written and i get this error no matter what

Paul Melos
Paul Melos
3,852 Points

If you want to run it in the python shell you will have to change your directory to wherever you unzipped the zip files. You can change directories in the shell by importing the os module.

#import the os module

import os

#show your current working directory


#change to the directory where you unzipped the files, note that I used forward slashes 
#because python will try to escape backslashes


1 Answer

drew mullen
drew mullen
1,555 Points

I think you have to change to the directory first.


cd rpg
python play.py


python ./rpg/play.py