GitHub Copilot: Fly With Python at the Speed of Thought

GitHub Copilot: Fly With Python at the Speed of Thought

GitHub Copilot is a thrilling new technology that promises to deliver to your code editor a virtual assistant powered by artificial intelligence, and it stirred up considerable controversy when it was released to the general public. Python is among the languages that are particularly well-supported by this tool. After reading this tutorial, youโ€™ll know whether GitHub Copilot is a risk, a gimmick, or a true game changer in software engineering.

In this tutorial, youโ€™ll learn how to:

  • Install the GitHub Copilot extension in your code editor
  • Transform your natural language description of a task into working code
  • Choose between multiple alternative intelligent code completion suggestions
  • Explore unfamiliar frameworks and programming languages
  • Teach GitHub Copilot how to use your custom API
  • Exercise test-driven development with a virtual pair programmer in real time

To continue with this tutorial, you need to have a personal GitHub account and a code editor such as Visual Studio Code or an integrated development environment like PyCharm.

Get Started With GitHub Copilot in Python

GitHub Copilot is the first commercial product based on the OpenAI Codex system, which can translate natural language to code in over a dozen programming languages in real time. OpenAI Codex itself is a descendant of the GPT-3 deep learning language model. The neural network in Codex was trained on both text and hundreds of millions of public code repositories hosted on GitHub.

Initially, the product was only available as a technical preview to a select group of people. This has changed recently, and today, anyone can experience the incredible power of artificial intelligence in their code editors. If youโ€™d like to take it for a test drive, then youโ€™ll need a subscription for GitHub Copilot.

Subscribe to GitHub Copilot

To enable GitHub Copilot, go to the billing settings in your GitHub profile and scroll down until you see the relevant section. Unfortunately, the service doesnโ€™t come free of charge for most people out there. At the time of writing, the service costs ten dollars per month or a hundred dollars per year when paid upfront. You can enjoy a sixty-day trial period without paying anything, but only after providing your billing information.

Students and open-source maintainers may get a free GitHub Copilot subscription. If youโ€™re a lucky one, then youโ€™ll see the following information after enabling the service:

GitHub Copilot Billing Status
GitHub Copilot Billing Status

GitHub will verify your status once a year based on proof of academic enrollment, such as a picture of your school ID or an email address in the .edu domain, or your activity in one of the popular open-source repositories.

For detailed instructions on setting up and managing your GitHub subscription, follow the steps in the official documentation. Next up, youโ€™ll learn how to install the GitHub Copilot extension for Visual Studio Code. If youโ€™d prefer to use GitHub Copilot with PyCharm instead, then skip ahead to learn how.

Install a Visual Studio Code Extension

Because Microsoft owns GitHub, itโ€™s no surprise that their Visual Studio Code editor was the first tool to receive GitHub Copilot support. There are a few ways to install extensions in Visual Studio Code, but the quickest one is probably by bringing up the Quick Open panel using Ctrl+P or Cmd+P and then typing the following command:

ext install GitHub.copilot

When you confirm it by pressing Enter, itโ€™ll install the extension and prompt you to reload the editor afterward.

Alternatively, you can find the Extensions icon in the Activity Bar located on the left-hand side of the window and try searching for the GitHub Copilot extension on the Visual Studio Marketplace:

GitHub Copilot Extension for Visual Studio Code
GitHub Copilot Extension for Visual Studio Code

You might also show the Extensions view in Visual Studio Code directly by using a corresponding keyboard shortcut.

After the installation is complete, Visual Studio Code will ask you to sign in to GitHub to give it access to your GitHub profile, which your new extension requires:

Authorize GitHub for VS Code
Authorize GitHub for VS Code

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

Unlock This Article

Already a member? Sign-In

The full article is for members only. Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Article

Already a member? Sign-In

About Bartosz Zaczyล„ski

Bartosz Zaczyล„ski Bartosz Zaczyล„ski

Bartosz is a bootcamp instructor, author, and polyglot programmer in love with Python. He helps his students get into software engineering by sharing over a decade of commercial experience in the IT industry.

ยป More about Bartosz

Each tutorial at Real Python is created by a team of developers so that it meets our high quality standards. The team members who worked on this tutorial are:

What Do You Think?

Whatโ€™s your #1 takeaway or favorite thing you learned? How are you going to put your newfound skills to use? Leave a comment below and let us know.

Commenting Tips: The most useful comments are those written with the goal of learning from or helping out other students. Get tips for asking good questions and get answers to common questions in our support portal.


Looking for a real-time conversation? Visit the Real Python Community Chat or join the next โ€œOffice Hoursโ€ Live Q&A; Session. Happy Pythoning!

Become a Member to join the conversation.

Keep Learning

Related Tutorial Categories: intermediate python tools