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 trial

Python Using Databases in Python Our Diary App Doing Data Entry

nakalkucing
nakalkucing
12,964 Points

/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 diary.py and ./diary.py

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(default=datetime.datetime.now)

    class Meta:
        database = db


def initialize():
    """Create the database and the table if they dont exist."""
    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()
nakalkucing
nakalkucing
12,964 Points

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

nakalkucing
nakalkucing
12,964 Points

I couldn't get diary.py 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"

nakalkucing
nakalkucing
12,964 Points

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 diary.py

This was suggested in this discussion by Kenneth.