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 trialvikas pal
11,563 Points./ is not working in workspaces
Please see the video first before giving the answer. I done the same as described in the video but it is not working.I do 'chmod +x diary.py' and it done as in video and when i do ./diary.py it says no such file or directory.Please tell me where i done mistake and then what to do now.my code is below.
#!/usr/bin/env python3
import datetime
from peewee import *
db=SqliteDatabase('diary.db')
class Entry(Model):
content=TextField()
timestamp=DateTimeField(default=datetime.datetime.now)
class Meta():
database=db
def initialize():
db.connect()
db.create_tables([Entry],safe=True)
def menu_loop():
"""show the menu"""
def add_entry():
"""add an entry"""
def view_entries():
"""view previous entries"""
def delete_entry(entry):
"""delete an entry"""
if __name__=='__main__':
initialize()
menu_loop()
Help me please.
Jennifer Nordell
Treehouse TeacherHi there! It sounds like there might be a problem in the file/directory structure. I'd be happy to help you troubleshoot it. However, this is going to require you providing a snapshot to your workspace. A snapshot can be created by clicking the camera icon on the upper right hand side and linking the resulting snapshot here. We can then fork the workspace and take a look around to see if we can find the problem!
vikas pal
11,563 Pointsyes i done it.now what to do next.i still have problem in it
Jennifer Nordell
Treehouse TeacherClick the link to the snapshot you just created and post the URL here so we can follow it.
vikas pal
11,563 PointsMichael Hulet
47,913 PointsHey vikas,
Whatever problem you're having is likely one that others have/will also run into, so could you have whatever conversation that goes on between you and Jennifer here, out in the open? It will almost certainly benefit others in the future, so if you could resolve your problems here and not in private, that'd be awesome
1 Answer
Jennifer Nordell
Treehouse TeacherHi there, vikas! I have forked your workspace and reviewed the video. I, like yourself, get the same error you get when following the instructions exactly. However, Kenneth does mention that some variation may be needed. There is another way to run it. But at this point in the project, running the program will not actually produce any output. So on the last line of the diary.py file I added this line to make sure it's actually running.
print("Hi there!")
Then in the console, type python diary.py
and you should see "Hi there!" printed to the screen. Hope this helps!
vikas pal
11,563 Pointsi still have problem and i am saying that kenneth run diary.py by typing ./diary.py instead of python diary.py and this is still not working in my workspaces.please help
Jennifer Nordell
Treehouse TeacherAnd as I stated, I could also not get ./diary.py
to work for me either. However, python diary.py
worked just fine. When you try that command, what happens?
vikas pal
11,563 Pointsohh sorry my english is not so good so i didn't catch it.so now what i can do and by using python diary.py it worked fine.
Jennifer Nordell
Treehouse TeacherType this into the console:
python diary.py
Please note that if you have not explicitly put any sort of print function in the diary.py
, there will be no output at this point. Even when Kenneth runs it and everything is correct, nothing happens. See the end of this video. I put the line print("Hi there")
at the end of diary.py
just to confirm that it was running.
vikas pal
11,563 PointsYes that working fine thank you for your great help and again please unblock me on twitter.
vikas pal
11,563 PointsBut my problem is still not solve that i can't use ./ .
Jennifer Nordell
Treehouse TeacherHi again vikas pal! I have been hard at work trying to figure out why this won't work. And I've even been visiting stack overflow. What I found there tends to point to some error in the line endings which are invisible to us and having to do with the encoding. Your file is encoded as utf8(dos). Mine is encoded as utf8(unix). I'm not sure if you copy/pasted from a Windows machine and it's not understanding the encoding or what exactly is going on. So, I was able to both reproduce the problem and provide a solution.
Here is my Python workspace that contains a copy that works with the shortcut and one that doesn't: https://w.trhou.se/ie9n1yrnho
If you type this in the console: ./diary.py
you will get the not found error. This is the one with utf8(dos)
However, if you type this in the console: ./diary2.py
it will run. This is the one with utf8(unix).
Feel free to fork this workspace and look around. The code itself is identical. Good luck!
note: Thanks to William Li for helping me isolate the problem
vikas pal
11,563 PointsIt worked fine .Now its working THank you Thank you so much for your great help and hard work and also Wlliam Li to help us.From now i am going to tag you instead of another person.haa joking but please help when i stuck another time in coding. Vikas
vikas pal
11,563 Pointsvikas pal
11,563 PointsKenneth Love