DEV Community

Cover image for VSCode & GitHub Codespaces for my Python playground
Giorgio Boa for This is Learning

Posted on • Updated on


VSCode & GitHub Codespaces for my Python playground

Today I did some experiments with Python, I decided to do this activity with GitHub Codespaces without installing Python on my machine.


GitHub repository

I started by creating my repository on GitHub and I named it python-playground.


Clone repository

I cloned the local repository by typing the command:
git clone
in the terminal.
I took the URL of the repository from GitHub, you can find it by pressing the Code button.


VSCode: Add Dev Container

Once the repository was cloned locally, via VSCode, I used the command:

Dev Containers: Add Dev Container Configuration Files...


To use this command you have to install the Dev Containers extension and you need to have Docker up and running in your local machine.

Run locally

With this approach (docker installed locally) you can use VSCode Dev Container feature as I described in this article 😊
Tidy up your machine with Visual Studio Code Dev Containers

Then I selected "Show All definitions"


I selected "Python 3"


Then I selected version 3.11


In this step I selected the Dev Container Features


VSCode will create for you this configuration file .devcontainer/devcontainer.json

// For format details, see For config options, see the
// README at:
    "name": "Python 3",
    "image": "",
    "features": {
        "": {}
    // Features to add to the dev container. More info:
    // "features": {},
    // Use 'forwardPorts' to make a list of ports inside the container available locally.
    // "forwardPorts": [],
    // Use 'postCreateCommand' to run commands after the container is created.
    // "postCreateCommand": "pip3 install --user -r requirements.txt",
    // Configure tool-specific properties.
    // "customizations": {},
    // Uncomment to connect as root instead. More info:
    // "remoteUser": "root"
Enter fullscreen mode Exit fullscreen mode

First Python code

I created a simple file to test if the solution works.


Push to GitHub

I pushed the local changes to GitHub via the
git push origin main command.


GitHub Codespaces

After sending the local changes to GitHub, I created a new GitHub Codespaces through this section.


A new URL has opened with this screen πŸš€



After the setup, which took a few minutes, I got a new instance of VSCode where I was finally able to use Python.



As you can see python command works like a charm. πŸ‘

And that's all... The process may seem complicated but it is very fast and intuitive.

Manage Codespaces

Inside GitHub we can manage our Codespaces: delete them, rename them and much more.




GitHub Codespaces pricing


Here you can read the documentation which explains in detail the costs of the service.

πŸŽ‰ As you can see it's super easy to use this functionality and I'm so happy about it. πŸ˜„

You canΒ follow me on Twitter, where I'm posting or retweeting interesting articles.

I hope you enjoyed this article, don't forget to give ❀️.
Bye πŸ‘‹

Top comments (8)

kasuken profile image
Emanuele Bartolesi

I think it’s not the right way to initialise Codespaces.
You don’t need Docker on your machine.
You can create everything online and then you can connect directly to Codespaces.

gioboa profile image
Giorgio Boa • Edited

I started my journey from my local machine to use also the VSCode Dev Container feature and in this case VSCode complaints about Docker πŸ˜… if you want only Codespaces support, start everything online is a good alternative too. thanks for your feedback 😊

gioboa profile image
Giorgio Boa

I added the Run locally section to explain better this concept. Thanks πŸ‘

Thread Thread
kasuken profile image
Emanuele Bartolesi

Ahhhhhh ok

balastrong profile image
Leonardo Montini

Thank you for this step by step guide!

The Codespaces feature seems a lot interesting and the integration with VSCode makes the setup process nice and clean.

You mentioned that the initial setup took a few minutes. Now that the environment has been created is it faster to launch the codespace instance?

gioboa profile image
Giorgio Boa • Edited

Yes, after the first initialisation is so much faster 😊 btw I used python but there are a ton of configurations ready to be used

balastrong profile image
Leonardo Montini

Great, that's the answer I was hoping for 🀩

Thank you again!

Thread Thread
gioboa profile image
Giorgio Boa

It's a docker container so is really fast and preserve the "last state" of your instance πŸ€—

🌚 Friends don't let friends browse without dark mode.

Sorry, it's true.