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 Inheritance Multiple Superclasses

[Errno 2] No such file or directory

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

This is the error I get when I try to run the play.py file. I have ran through the code 3 times to make sure spelling is perfect, and that I created the play.py file under the rpg folder

before typing in "python play.py" to run the file; I entered "cd rpg', pressed enter and it added the /rpg$ to the end of workspace. Typed in "python play.py" to run the file and it worked.

Im also getting this issue ¯_(ツ)_/¯

2 Answers

Seeing Kenneth made a new folder with these files, we need our console to be able to locate it, there are two methods to achieve this:

  1. Go to the folder/directory where the script is located.. Seeing we are currently in the ~/workspace directory.. if you type cd rpg it will put you in the ~/workspace/rpg folder.. cd stands for change directory
  2. Loading the python script using the folder. Alternatively, you could type python rpg/play.py which tells the console to look in the rpg folder for the play.py script

Hope this helps!

Thanks, Peter. I tried your second method and it worked!

I am using VS Code to follow along instead of Workspaces. I closed VS Code, went to the folder containing my program file on my hard drive, right clicked (Windows OS) and chose "Open with Code". Then I could run it from the TERMINAL in VS Code.

But, now I've get the ValueError from the Character class.

:::EDITED::: Remember to SAVE your files before getting mad when they don't run and you've typed everything EXACTLY like the tutorial.