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 trialKyle Harris
2,149 Points[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
Benyamin Kohanchi
Courses Plus Student 2,342 PointsIm also getting this issue ¯_(ツ)_/¯
2 Answers
Peter Lord
10,034 PointsSeeing 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:
- 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
- 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!
Jonathan Tucker
Ubora | Web Development Techdegree Student 16,987 PointsThanks, Peter. I tried your second method and it worked!
Laura Owens
15,044 PointsI 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.
Kyle Harris
2,149 PointsKyle Harris
2,149 Pointsbefore 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.