Image for a Python environment having Jupyter Notebooks with Unix surrounded by a common toolchain.
1.8K
Python Playground
2026Jan Rother
[email protected]
github.com/JanRother
https://janrother.de/
The Python Playground is meant to be a starting point for Python projects. It provides a pre-configured development environment using DevContainers and a basic project structure. The project is set up to use Poetry as package manager and Jupyter Notebooks for interactive coding sessions.
The local installation of this project is currently not intended.
A DevContainer allows developers to define a development environment in a container. This leads to a consistent development environment across different machines and therefore simplifies the setup process while also reducing dependencies on the host system. Some of the most relevant Integrated Development Environments (IDEs) already support the use of DevContainers:
Any configuration regarding the development container is stored in the ./.devcontainer/ directory. It must not be removed.
To use the DevContainer feature, the following software has to be installed on the host system:
winget install -e --id Docker.DockerDesktop.winget install -e --id Microsoft.VisualStudioCode.As of now, it is recommended to use either Visual Studio Code or GitHub Codespaces to access the development container. Other IDEs are currently adopting this technology, but still have to catch up.
A Docker Image is already configured and can be used to start a development environment right away or to include it as base image in a custom Dockerfile. The image is build from the Dockerfile located in the .devcontainer directory.
To use the Docker Image directly, run
docker build -t python -f .\Dockerfile .
and
docker run -it python
git clone <your-fork-url>.To use the DevContainer remotely, no software has to be installed on the host system. Other requirements have to be met:
.devcontainer directory, has to be created.Code button.Codespaces from the dropdown menu.Create Codespace on Main to create a new code space.Note:
Visual Studio Code provides an option to connect to a DevContainer in the cloud.
Therefore, the GitHub Codespaces extension has to be installed in the editor.
The DevContainer can be adjusted to every need. The Dockerfile defines the base image and the tools installed in the container. The devcontainer.json file defines the settings for the development container, thus shaping the development environment.
It is recommended to leave the Dockerfile as-is. It uses the python image from hub.docker.com as base image and configures it for the Python environment using Poetry. Specifiers can easily be modified using ARG variables.
If changes to the development environment are necessary, the devcontainer.json file can be adjusted. It uses the image created by the Dockerfile and defines the settings for the development container. Besides its behavior, precise settings for the editor vscode or the IDEs jetbrains can be defined. The extensions array can be used to install additional extensions in the development container.
The DevContainer provides a pre-configured ZSH shell. It can be further customized by adjusting the .zshrc file. The starship.toml file can be used to configure the prompt of the shell.
If after initial creation of a project, a higher compatibility should be achieved, the base images and packages used should be pinned to a specific version.
To configure the Python Virtual Environment (VENV), the package manager Poetry is used.
Ensure the correct installation of Poetry by running
poetry --version
If the command returns a version number, Poetry is installed correctly. If not, the installation can be done by running
python -m pip install poetry
In Poetry, dependencies are managed in the pyproject.toml file. To install the dependencies, run
poetry install --no-root
To get the path to the virtual environment, run
poetry env info --path
The result of this command can be used to activate the virtual environment by running
source <path-to-venv>/bin/activate
The virtual environment is now activated and can be used.
To create a kernel for Jupyter Notebooks, the following command has to be run:
ipython kernel install --name "python-venv" --user
This command creates a kernel named python-venv that can be used in Jupyter Notebooks. The kernel is based on the virtual environment created by Poetry.
Now, the Jupyter Notebooks can be used.
Have fun!
Content type
Image
Digest
sha256:01da1229c…
Size
525.8 MB
Last updated
3 months ago
docker pull janrother/python-playground