No such file or directory when the Python program is saved and run on the terminal

Asked 2 years ago, Updated 2 years ago, 36 views

I'm a huge beginner.
After entering the command as per the book Python, CC saved it as draw_tree.py on the desktop, but typing $pythondraw_tree.py on the terminal did not launch the title as per the book and did not write the diagram.I have made a lot of mistakes in thinking whether the file name is bad, the file is stored in a bad location, or whether there are typographical errors or omissions, but it is difficult to solve, so I will write it down.Please let me know if you are kind.

Books, programs created with everyone's Python in mind

python python3

2022-09-30 19:40

1 Answers

The file you created (tree.py) seems to have been saved to your desktop, but right after opening the terminal, you are in the home directory, so I think you can't find the file even if you run $python....

Where the file is stored
/User/Username/Desktop/draw_tree.py

location immediately after opening the terminal
/User/Username/

Run cd Desktop at the terminal to move the directory, and then view the file list in ls to see if you see the file you created.
Then try running pythondraw_tree.py again.


2022-09-30 19:40

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.