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 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

Peter Lord
Peter Lord
10,021 Points

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!

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.