Python Using Databases in Python Our Diary App Doing Data Entry

/usr/bin/env: 'python3\r': No such file or directory But I followed Kenneth's code exactly!

I know there are several questions and answers about this already, but i still can't fix my problem. :P

In the video Kenneth types: chmod +x and ./

I followed this and received back the following error: /usr/bin/env: 'python3\r': No such file or directory

If anyone can tell me how to run this I would really appreciate it. Thanks in advance! :)

Here's my code:

#!/usr/bin/env python3

import datetime

from peewee import *

db = SqliteDatabase('diary.db')

class Entry(Model):
    content = TextField()
    timestamp = DateTimeField(

    class Meta:
        database = db

def initialize():
    """Create the database and the table if they dont exist."""
    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__':

Problem solved. Found the answer here. Thanks Chris Freeman!

I couldn't get to run. I was getting this error: /usr/bin/env: 'python3\r': No such file or directory But I followed the steps you gave in the question I linked to. That fixed it! :)

2 Answers

Hi, could you post the full code? I tried to edit the code in 30 minutes and still get "No such file or directory"

Hi Phu Tran! The above code is the full code. In the next video Kenneth does change this code, so if that's the code you want, let me know.

If you're still getting the "No such file or directory" error, try typing this into the console: python3

This was suggested in this discussion by Kenneth.