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 Advanced Objects Emulating Built-ins

Swan The Human
seal-mask
.a{fill-rule:evenodd;}techdegree
Swan The Human
Full Stack JavaScript Techdegree Student 19,338 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,905 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

os.getcwd()

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

os.chdir('C:/whatever/directory')

1 Answer

drew mullen
drew mullen
1,555 Points

I think you have to change to the directory first.

Try

cd rpg
python play.py

OR

python ./rpg/play.py