Python Using Databases in Python Our Diary App Doing Data Entry

getting a bunch of errors with ./

my field seems to run fine when i type in my terminal. However, when i type chmod +x and then ./, I get the following errors:

./ line 1: import: command not found

./ line 3: from: command not found

./ line 5: syntax error near unexpected token `('

./ line 5: `db=SqliteDatabase('diary.db')'

can anyone explain why I am getting these errors?



Benjamin Lange
Benjamin Lange
16,176 Points

Can you post a snapshot of your workspace?

vikas pal
vikas pal
8,545 Points

Kenneth Love please tell this question

2 Answers

Kenneth Love
Kenneth Love
Treehouse Guest Teacher

I'd have to see the code before I could answer definitively, but it sounds like it's maybe being run by the wrong version of Python? I'm really not sure how far back you'd have to go before from X import Y wouldn't work, though.

Kathryn Klarich Those don't look like errors generated by python to me. They look like errors generated by your shell, which is what runs "python" with arguments "" when you type in python

How are you running your program? If you're doing . or . ./, note that . is a command in most shells, which says "run this file in the current namespace" i.e. not what you want.

If ./ still fails, double check that the first line is indeed #!/usr/bin/env python3. If it is, and it's still not working, try running /usr/bin/env python3 yourself and tell me how that goes.

Thanks! the second method worked for me.