Use Codex CLI to Enhance Your Python Projects: Installing & Setting Up
Skills:
AI-Assisted Code Review70%
Key Takeaways
Teaches installing and setting up Codex CLI for Python projects
Full Transcript
Hey there. I'm Rodrigo, and it's my pleasure to welcome you to this real Python course on how to use Codex CLI to enhance your Python projects. This course is for you if you want to learn how to use LLMs from the comfort of your terminal, and you're interested in using tools from OpenAI, namely Codex CLI. In this course, you're going to learn to install and set up Codex CLI so that you can use it directly from your terminal. You're going to use Codex CLI to work on a almost finished Python project that will be provided as a downloadable for you. You'll learn about the Codex CLI plan mode and its advantages. And you'll also implement and refine features in your Python project without writing a single line of code, because you'll be using natural language instructions. Before you start using Codex CLI, and by the way, CLI stands for command line interface, before you start using this, you'll want to check that you have all of the prerequisites that are necessary for this course. In this case, you just need to make sure you install UV on your machine. Now, don't worry if you've never used UV before, because you will only use UV a couple of times, and the lessons will guide you through the exact commands you need to type. But, you do need to have UV installed. So, if you don't have it yet, feel free to pause and install it now. Now, another thing to keep in mind is that since you're going to be interacting with LLMs through Codex CLI, you'll have to type in prompts. And one thing that's important to keep in mind is that while the prompts that were used in this course are available in the downloadable materials so that you can copy and paste them, the prompts are provided for convenience, because you don't need to type in the exact same prompts. After all, LLMs are non-deterministic, and even if you type in the exact same prompts, you'll get slightly different results. So, you should be more focused on having a similar sort of output that fulfills more or less the same constraints than being worried about getting the exact same output as the one that's shown on the lessons. All right, with this out of the way, when you're ready to start setting up your projects and everything on your machine, feel free to move on to the next lesson. In order to use Codex CLI to implement a feature in a project, you need a project to work on. And that's going to be provided as a downloadable for this course. So, there's a project called RP Contacts that you will want to download. And after you download it, you will want to CD into the folder RP Contacts. Now, if you inspect the contents of this folder with ls -al, you should find a couple of files and directories already there. Namely, a source directory that contains the source code for a partially completed project and a couple of files that have project metadata and whatnot. This Python project is managed by UV. That's why in the intro lesson, UV was mentioned as a prerequisite. So, assuming you followed the installation instructions and that you have UV installed, you can now try to run the app from the project. And to do that, you just type UV space run space RP Contacts. And once you press enter, UV will automatically set up a virtual environment, it will install the dependencies for this project, and it will open a TUI, a text user interface like the one you see on the screen. Now, this TUI is supposed to help you manage your contacts. So, this is a contacts book app that was built with Textual and Python. And you can press the add button on the top right corner of the interface, and when you do, it opens a modal screen where you can create a contact. For example, you can just fill in this with some random information and a an example.example.com. And then you can, for example, use your keyboard keys. You can press tab twice and then enter to create the contact. So, this is what the interface looks like, and it will list all of the contacts you create. Now, the thing is the buttons delete and clear all that are also shown on the right, those are there in the user interface, but they do not work yet. If you highlight the contact you create and you press the button delete, it does not delete the contact. And if you try and click the button clear all, it also doesn't clear all of the contacts. And this is precisely the feature that you will implement in this course. Now, to exit the app, you will want to press Q to open a confirmation dialog, and then you press yes to quit the app. So, this lets you test that you are able to download everything and that you've set up the environment correctly. What you also need to do is initialize a GitHub repository at the root of the project. The reason being you're going to use Code CLI to work in this project, which means LLMs will change your code. And you never know if the changes that the LLM makes are good or not. So, having a GitHub repository and frequently committing the current changes in your repo makes it easy to roll back any unwanted changes or any bad changes that the LLM makes. So, to initialize the repository, you can type git init {dot} and then you can type git add {dot} to add everything in the directory. You already have a useful {dot} gitignore file, so you can confidently add everything and then what you'll want to type is git commit {dash} m first commit. You will want to press enter to effectively commit the initial state of your project into the repository, so that the changes you make in the upcoming lessons can be easily rolled back if something goes wrong or if something doesn't look how you would want it to look like. Once you've completed all of these setup steps, feel free to move on to the next lesson where you'll start setting up Codex CLI. Now that everything else is set up, now you want to install the Codex CLI. And in order to do that, make sure you open the OpenAI documentation on the Codex CLI and follow the installation instructions there. And the reason I'm asking you to open the documentation explicitly is because these things keep changing so fast and the Codex CLI is updated so often that by the time you watch this video course, the preferred installation method might be different. At the time of the recording, OpenAI shows you the single commands you need to run which installs the Codex CLI through NPM, which obviously assumes you have NPM installed. So, this should work for Windows, Linux, and Mac OS users. You press enter, you give it a couple of seconds, and then the Codex CLI should be installed. To double-check that it was installed successfully, you'll want to run codex {dash} {dash} version to check whether the Codex CLI is accessible and was installed successfully. The version 0.106 is the most recent version, Again, at the time of this recording, the Codex CLI is updated so often that by the time you install it and you watch this, you'll be in a more recent version of the Codex CLI. The next step is setting up authentication so that Codex can access your OpenAI account. For that, you'll need either a paid tier of an OpenAI account or a valid API token. So, make sure you have either and then proceed to the next lesson so you can set up your Codex CLI.
Original Description
Download your free Python Cheat Sheet here: https://realpython.com/cheatsheet
Free Python Skill Test with instant level + learning plan: https://realpython.com/skill-test
Want to learn faster? Become a Python Expert with unlimited access to 5,000+ tutorials, videos, and exercises: https://realpython.com/start
This is a preview of the video course, "Use Codex CLI to Enhance Your Python Projects". After watching this video course, you’ll be able to use Codex CLI to add features to a Python project directly from your terminal. Codex CLI is an AI-powered coding assistant that runs inside your terminal. It understands your project structure, reads your files, and proposes multi-file changes using natural language instructions.
Instead of copying code from a browser or relying on an IDE plugin, you’ll use Codex CLI to implement a real feature in a multi-file Python project directly from your terminal.
This is a portion of the complete course, which you can find here: https://realpython.com/courses/use-codex-cli-enhance-your-python-projects/
The rest of the course covers:
- Setting Up Codex
- First Steps With Codex
- Using Plan Mode in Codex CLI
- Implementing the Plan
- Refining Project Features
- Use Codex CLI to Enhance Your Python Projects (Quiz)
🐍 Become a Python expert with real-world tutorials, on-demand courses, interactive quizzes, and 24/7 access to a community of experts at https://realpython.com
▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰
🐍 Start Here → https://realpython.com/start
🗺️ Guided Learning Paths → https://realpython.com/learning-paths
🎧 Real Python Podcast → https://realpython.com/podcast
📚 Python Books → https://realpython.com/books
📖 Python Reference → https://realpython.com/ref
🧑💻 Quizzes & Exercises → https://realpython.com/quizzes
🎓 Live Courses: https://realpython.com/live
⭐️ Reviews & Learner Stories: https://realpython.com/learner-stories
▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰
Watch on YouTube ↗
(saves to browser)
Sign in to unlock AI tutor explanation · ⚡30
More on: AI-Assisted Code Review
View skill →
🎓
Tutor Explanation
DeepCamp AI