Skip to main content
Gitpod comes with great support for Python built-in. Still, depending on your project, you might want to further optimize the experience.

Python Project Examples

Before we get started, here are some examples of already-gitpodified repositories!

Pandas

Welcome data scientists! This part of the guide will show you how to configure Gitpod for Pandas development.

Try Pandas in Gitpod

To see a minimal project with Pandas installed and configured, please check out gitpod-io/Gitpod-Pandas: Open in Gitpod

Use Gitpod for Pandas development

Pandas Team has their official docs on how to use Gitpod for Pandas development. Please check out Pandas Team’s Gitpod guide.

Jupyter Notebooks in VS Code

For the best experience with Jupyter, please open your Gitpod workspaces in VS Code Desktop.

Python Versions

Run pyenv versions to see which Python versions are pre-installed in Gitpod. The easiest way to install a new Python version is to use pyenv install <VERSION>. For example, suppose you wanted to install Python 3.6.4, you would run pyenv install 3.6.4. You can switch between Python versions using pyenv local <VERSION>. For example, if you wanted to switch to Python version 2.7.17 you would run pyenv local 2.7.17. This will create a .python-version file that controls which Python version is the default in your project. If you want to set up a custom dockerfile so that you don’t have to repeat the process, here’s how your .gitpod.Dockerfile could look like:

Start tasks

You can start building your project when, or even before you start your Gitpod workspace. Are you using a requirements.txt file to manage dependencies? If so, add this to your .gitpod.yml to automatically pre-install all dependencies when starting a workspace:

Linting

You can create a setup.cfg or a pycodestyle.cfg in the project root and adjust pycodestyle rules there like this:
You’ll need to refresh the browser in order to update these rule. Source.

VS Code Extensions

While the most popular Python VS Code extensions are built into Gitpod, here are a few “nice to have” extensions that you can use as well.

ARepl for Python

ARepl for Python is helpful for constantly checking your code and debugging. To install this extension for your repository, add the following to your .gitpod.yml:

Python Test Explorer

Easily test your python code with the Python Test Explorer. To add this to your repository add the following to your .gitpod.yml

GUI Applications with wxPython

To install wxPython to your repository please add the following to your .gitpod.Dockerfile. If you don’t have one, simply run gp init and commit the two generated files.
Here is a corresponding .gitpod.yml example:

We also support other GUI frameworks such as Kivy and PyQt
Here are some other examples of Python GUI applications in Gitpod:

Debugging

Here is a quick clip on how to automatically configure debugging for Python! So, basically in this video we:
  1. First, open the Python file that we want to debug
  2. Then, go to the debug menu and select “Add Configuration…”
  3. Next, in the dropdown choose “Python”
  4. Next, choose “Python File” as the debug configuration
  5. Finally, start debugging your Python program!
You can also create the Python debug configuration file manually To start debugging your Python application in Gitpod, please create a new directory called .theia/, and inside add a file called launch.json, finally, add the following to it:
Then, simply open the Python file you want to debug, open the Debug panel (in the left vertical toolbar, click the icon with the crossed-out-spider), and click the green “Run” button.
To see a basic repository with Python debugging enabled, please check out gitpod-io/Gitpod-Python-Debug: Open in Gitpod

Further Reading