0

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

9
  • The path to the file in your command line is /workspaces/187923852/faces.py. But faces.py is in the faces directory one level down. Commented Mar 22 at 17:24
  • what can i do to get rid of this error? Commented Mar 22 at 17:30
  • Use the correct path: /workspaces/187923852/faces/faces.py. Commented Mar 22 at 17:31
  • I am confused, couldn't work this out. Can you help me any other way? Commented Mar 22 at 18:38
  • You say that you are in the right directory, but we cannot see which that is. Please enter the pwd command to display the actual location that your shell is at, and update your question with the details. Commented Mar 23 at 17:27

1 Answer 1

0

You should start be reading the Codespace documentation. Once you do, you will find there are (at least) 3 ways to run your code:

  1. Click on the arrow ("Run") button near the top right corner to execute the program.
  2. Select the faces.py file 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 the python faces.py command.
  3. Or, enter cd faces at the command prompt, then enter the python faces.py command. This has the same result as method 2 above.
Sign up to request clarification or add additional context in comments.

2 Comments

These ways aren't working. Codespace is saying I am on the wrong file or directory.
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.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.