enter image description hereI am trying to execute my Python code on the command line in the CS50 Codespace IDE. After I enter the command, I get a "can't open file" error message. How to I determine if I am in right directory with the faces.py file? If I'm in the wrong directory, how do I get to the correct directory?
Image of CS50 IDE
1 Answer
You should start be reading the Codespace documentation. Once you do, you will find there are (at least) 3 ways to run your code:
- Click on the arrow ("Run") button near the top right corner to execute the program.
- Select the
faces.pyfile in the File display (on the left) and pick "Run in Integrated Terminal" from the pop-up menu. This will change the command prompt to match the folder name. Then enter thepython faces.pycommand. - Or, enter
cd facesat the command prompt, then enter thepython faces.pycommand. This has the same result as method 2 above.
2 Comments
Ahnam Ahmed
These ways aren't working. Codespace is saying I am on the wrong file or directory.
kcw78
I don't know what to tell you. I use the 1st method (Run button) most often. It should always work. Methods 2 and 3 are the "old school" ways to run from the command line and they should also work. Here are 2 Linux commands to diagnose. Use the
cwd command to get the name of the current working directory. It should be /workspaces/187923852/faces. Use the ls command to list the files in your current directory/folder. You should see faces.py listed.
/workspaces/187923852/faces.py. Butfaces.pyis in thefacesdirectory one level down./workspaces/187923852/faces/faces.py.pwdcommand to display the actual location that your shell is at, and update your question with the details.