Locked learning resources

Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Locked learning resources

This lesson is for members only. Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Installing the Todolist App

Music: Living Voyage by Kevin MacLeod is licensed under a Creative Commons Attribution 4.0 license. creativecommons.org/licenses/by/4.0

00:00 In the last lesson, we used Gemini to explore the project and we learned that it’s a todolist application that tries to use emoji when you’re adding a task. Let’s dive a bit deeper and actually try out the application.

00:12 So on the left side we have Gemini and the right side I’m in the same folder in the project with a normal terminal, so not inside of Gemini. Let’s start by using Gemini and ask Gemini about how to start the application and what potential first steps could be.

00:30 How do I start the todolist application and how do I add a task?

00:37 And this time, in order to understand the application better, Gemini wants to use the ls command. And since Gemini is not just allowed to do anything, it asks you if it is allowed to do so.

00:52 There you have the option to allow it once, allow it always, or suggest changes. Again, you can use the up and down arrow keys to make a selection. And personally, with commands like the ls command, which is a non-destructive command, it’s just helping Gemini to get an overview of folders, I like to say, yeah, always allow.

01:14 Don’t ask me if you want to use the ls command.

01:21 And again, you can see Gemini going over your project and getting its thoughts together. And here again, happens something peculiar. It kind of looks like Gemini stopped during thinking.

01:38 So it says like, okay, I reviewed those files, blah, blah, blah, blah, blah. And then the last line is, so I’ll now explain how to run the app, add the tasks, but there is no explanation.

01:50 So in this case, let’s say “Yes, please explain”.

01:59 And then we get the output that I hoped to get in the first place. We have a nice structured list, a command to start the application, and then how to add a task, and examples.

02:10 So let’s copy one of the examples

02:14 and paste it in the terminal on the right side, which shows the command python -m src.todolist add Buy groceries.

02:23 And again, we’re running into an error. There is a ModuleNotFoundError: No module named rich, which, if you have ever worked with third-party packages, makes sense to you because we downloaded the todolist application, but we didn’t do anything else, right?

02:39 So we didn’t create a virtual environment, we didn’t run a pip install for external dependencies, although Gemini was telling us that this application uses external dependencies.

02:50 Let’s go back to Gemini and hint it, hopefully, into the right direction. Didn’t you forget something? Do you think that the commands would work right out of the box?

03:05 And there we go. Gemini says like, oh, I missed a step. I need to check for and install dependencies before running the application. I’ll inspect pyproject.toml to identify them and then explain the pip installation process, and saying like, yeah, you are right, I apologize.

03:22 And mentioning the third-party packages.

03:26 Lastly, it suggests to run pip install -e . and asks to allow the execution of the pip command. And this right here is a very crucial step when working with AI.

03:38 It seems like there are many crucial steps here and there. If you’re not knowledgeable about what’s happening here, you could just say like, yes, why not?

03:47 Let’s allow this once. But if you have ever worked with Python projects and you know there is something like virtual environments, then just running pip install -e . and potentially after that pip install openai peewee platformdirs and rich and so on, you will install this package and the other packages globally on your system.

04:10 Usually it’s more recommended to install them in a virtual environment so they have their own little space where they can live, and you don’t pollute your whole system with packages.

04:20 So here, I don’t want to say yes, allow once, and for sure I don’t want to say yes, allow always, but I want to suggest changes,

04:29 and hereby I cancel the request, and I want to tell Gemini to not perform those commands, but tell me what to do.

04:38 Don’t perform the commands yourself, but tell me what I should do.

04:47 And again, it runs into the same prompt asking me to run pip install -e . That’s a little bit annoying. And that is usually the point, honestly, where I don’t want to continue to argue with AI, but do the stuff myself.

05:05 So let’s hop to the right side where we are in the terminal and do the installation of the package correctly. I’m in the terminal, and let’s first check what is in this folder.

05:17 So we have a pyproject.toml file and the src/ folder. So first thing is to create a virtual environment, and you can do so by typing python -m venv and then .venv as the name of your virtual environment.

05:34 Once you press Enter, you are creating the virtual environment. Now you need to activate it. Here on macOS, I do it by typing source .venv/bin/activate.

05:46 And now I can see that I’m in the virtual environment because there I see the .venv in parentheses before my prompt. And now I actually can use the pip install -e . command that Gemini was suggesting, because now I have a virtual environment and I have it activated.

06:03 And now I have like this safe space where I can install the package and its dependencies.

06:09 Let’s copy the command, paste it on the right side of the terminal, press Enter,

06:16 and it looks like pip wanted to install the package in editable, but runs into an error. This is a moment to actually go back to AI and ask them, hey, what is going on here?

06:30 So let’s copy all of that, making sure to not use the versioning notice there because we don’t want to make Gemini think that it’s just about an outdated pip version, but there is something in the pyproject.toml file for us that doesn’t work at the moment.

06:49 So let’s copy the error message, go into Gemini. There, we still have the dialog open, so no suggest changes. And then recount the steps to Gemini and say what error happened.

07:03 I created a virtual environment, activated it, and ran pip install -e ., but I got this error. How can I fix it?

07:11 And then paste the error in there.

07:18 And then Gemini is saying, “The user’s pip install failed because README.md is missing as specified in pyproject.toml.

07:25 I create an empty README.md in the project root and then advise them to rerun the install commands. And I’m creating the file now”. And this time I say yes, I allow this, and create this empty README.md file.

07:47 Alright, again, it seems like Gemini is lost in its thoughts, and ending with, “Okay, README.md is created. I’ll now tell the user I fixed the file and they should re-run pip install”, but they don’t really tell us.

08:00 So let’s take it from here and run pip install -e . again.

08:09 And now it works. We’re in the virtual environment, we are installing the package as editable. That means we can still work with our todolist code, and still use it as an installed package.

08:21 And since we use it as an installed package, we also grabbed the dependencies right away. So that was something which before I wasn’t entirely sure about.

08:30 I thought that we might need to pip install the dependencies ourselves, but the pyproject.toml file looks like it has all the dependencies noted there, and everything should be working now.

08:43 So let’s try out the command from before, which is python -m src.todolist add "Buy groceries". That was the command that gave us a ModuleNotFoundError before.

08:57 Nice. Now we get a reply saying Pending: Buy Groceries. And since we haven’t added anything with openai, we don’t get the emoji, which is a little bit of a downer because I like emoji, but it’s also cool to see that it works without getting an error if we don’t have an OpenAI connection there to get emoji information.

09:19 Okay, and now that we did this little round trip of getting the application to work and seeing how Gemini can help there or not, let’s go more into the Gemini area and the next lesson where we will work a little bit on the documentation of this project.

Become a Member to join the conversation.