メインコンテンツまでスキップ

Python Development Environment

Last updated on July 24, 2025

Overview

This guide provides a simple and consistent way to start a new Python project. It covers installing Python, setting up a virtual environment, managing dependencies, running code, and optionally using Docker for containerized development.

Setup

1. Install Python

sudo apt update
sudo apt install python3 python3-venv python3-pip

2. Create a Project Directory

mkdir my_project && cd my_project

3. Create and Activate a Virtual Environment

python3 -m venv .venv
source .venv/bin/activate

4. Add a requirements.txt file

Create a requirements.txt file with your project dependencies:

cat <<EOF > requirements.txt
accelbyte-py-sdk
bitarray
httpx[http2]
mmh3
PyJWT[crypto]
PyYAML
requests
websockets
EOF
pip install -r requirements.txt

5. Write and Run Code

mkdir src
cat <<EOF > src/app.py
import accelbyte_py_sdk

print(accelbyte_py_sdk.get_version(latest=True, full=True))
EOF
python src/app.py

6. Run with Docker (Optional)

# Dockerfile

FROM python:3.12-slim

WORKDIR /app

COPY requirements.txt .
RUN pip install -r requirements.txt
COPY . .

CMD ["python", "src/app.py"]
docker build -t my-app . && docker run --rm my-app