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 trialBruce Whealton
3,619 PointsWhy did I get No such file or directory when trying to run ./diary.py?
I am working in the site Workspaces. I see that my question includes the place in which I am working and where I was last trying to do something. So, I added the !# at the top of diary.py, I added +x permission. Then I tried to run ./diary.py and got an error saying that No such File or directory. Bruce
5 Answers
Chris Freeman
Treehouse Moderator 68,441 PointsHi Bruce, You've added a "bang-she" (!#), instead of a shebang (#!). How I remember is an exclamation point is sometimes called a "bang" so a shebang should end in a bang!. also add the full shebang #!/usr/bin/env python3
Gabbie Metheny
33,778 PointsIt looks like this was resolved in this question by Iain Simmons . Kenneth Love , is it possible to add this to the teacher's notes for the video? It looks like it's a pretty common issue.
If you run the code in the video and get "No such file or directory":
treehouse:~/workspace$ chmod +x diary.py
treehouse:~/workspace$ ./diary.py
: No such file or directory
Try running the following line, then the two lines from above again:
sed -i 's/\r//g' diary.py
Chris Freeman
Treehouse Moderator 68,441 PointsTagging Craig Dennis who is pickup Python coverage since Kenneth left Treehouse
Connor James
5,380 PointsI have this same problem in Workspaces. Not the bang she, but the : No such file or directory. Any suggestions? Chris Freeman Kenneth Love
Kenneth Love
Treehouse Guest TeacherIt can't find the database file? Can you copy and paste the entire error message?
stephenmelendy
3,578 PointsI am having the same error.
Here is my console:
treehouse:~/workspace$ chmod +x diary.py
treehouse:~/workspace$ ./diary.py
: No such file or directory
treehouse:~/workspace$ ls
diary.db diary.py students.db students.py
treehouse:~/workspace$
Here is a copy of my code at top:
#!/usr/bin/env python3
from peewee import *
import datetime
db = SqliteDatabase('diary.db')
Kenneth Love
Treehouse Guest TeacherHmm, I wonder if something has changed in how Peewee or sqlite3
finds the database file?
Try giving an explicit path: db = SqliteDatabase('./diary.db')
If that doesn't work, we can find the path with os.path
but let's leave that for later.
stephenmelendy
3,578 PointsHi Kenneth, thank you for the reply. The explicit path didn't work, but if this is only the difference between typing "python diary.py" vs "./diary.py", I am perfectly fine leaving it as a peculiarity.
Gabbie Metheny
33,778 PointsKenneth, I am receiving the exact same error message as the others here, and the explicit path did not work. Have you had any insight into this problem since February? Thank you!
Jason Whitaker
12,252 PointsJason Whitaker
12,252 PointsI type it exactly, but I'm having the same problem. Below is my diary.py
Chris Freeman
Treehouse Moderator 68,441 PointsChris Freeman
Treehouse Moderator 68,441 PointsJason, are running this in Win, in Mac, in Linux, or In Workspaces?