{"library":"pymunk","title":"Pymunk","description":"Pymunk is an easy-to-use pythonic 2D physics library designed for games, demos, and simulations. It is built on top of Munk2D, a fork of the robust Chipmunk2D C physics library. First released in 2007, Pymunk remains actively developed and maintained, with its current version being 7.2.0, and has a regular release cadence with several updates per year.","language":"python","status":"active","last_verified":"Sun May 17","install":{"commands":["pip install pymunk"],"cli":null},"imports":["import pymunk","from pymunk import Space","from pymunk import Body","from pymunk.shapes import Circle, Poly, Segment","from pymunk import Vec2d"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import pymunk\n\n# 1. Create a Space (the simulation world)\nspace = pymunk.Space()\nspace.gravity = 0, -981  # Set gravity (e.g., 9.81 m/s^2 downwards)\n\n# 2. Create a Body (the physical object)\nmass = 1\nmoment = pymunk.moment_for_circle(mass, 0, 10) # Moment of inertia for a circle\nbody = pymunk.Body(mass, moment)\nbody.position = 50, 150 # Initial position of the body\n\n# 3. Create a Shape (for collision detection) and attach to the Body\ncircle_shape = pymunk.Circle(body, 10) # 10 is radius\ncircle_shape.friction = 0.7\ncircle_shape.elasticity = 0.9\n\n# 4. Create a static ground for the ball to land on\nground_shape = pymunk.Segment(space.static_body, (0, 0), (200, 0), 5) # From (0,0) to (200,0) with radius 5\nground_shape.friction = 0.7\nground_shape.elasticity = 0.9\nground_shape.color = (0, 0, 0, 255)\n\n# 5. Add the Body and Shape to the Space\nspace.add(body, circle_shape, ground_shape)\n\n# 6. Simulate the physics\nprint(f\"Initial position: {body.position}\")\nfor i in range(100): # Run 100 steps of the simulation\n    space.step(1 / 60.0) # Advance the simulation by 1/60th of a second\n    if i % 10 == 0:\n        print(f\"Step {i}: Position: {body.position}\")\n\nprint(f\"Final position: {body.position}\")","lang":"python","description":"This quickstart demonstrates setting up a basic Pymunk simulation with a falling circle bouncing on a static ground. It covers creating a `Space`, `Body`, `Shape`, applying gravity, and stepping the simulation forward.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":{"tag":null,"tag_description":null,"last_tested":"2026-05-17","installed_version":"7.2.0","pypi_latest":"7.2.0","is_stale":false,"summary":{"python_range":"3.10–3.9","success_rate":100,"avg_install_s":2.1,"avg_import_s":0.06,"wheel_type":"wheel"},"results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"pymunk","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0.05,"mem_mb":2.4,"disk_size":"22.7M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"pymunk","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":2.1,"import_time_s":0.03,"mem_mb":2.4,"disk_size":"24M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"pymunk","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0.09,"mem_mb":2.5,"disk_size":"25.2M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"pymunk","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":2,"import_time_s":0.08,"mem_mb":2.5,"disk_size":"26M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"pymunk","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0.07,"mem_mb":2.2,"disk_size":"17.1M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"pymunk","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":1.8,"import_time_s":0.06,"mem_mb":2.2,"disk_size":"18M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"pymunk","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0.06,"mem_mb":2.5,"disk_size":"16.8M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"pymunk","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":1.9,"import_time_s":0.06,"mem_mb":2.3,"disk_size":"18M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"pymunk","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0.04,"mem_mb":2.4,"disk_size":"23.0M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"pymunk","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":2.5,"import_time_s":0.04,"mem_mb":2.4,"disk_size":"24M"}]}}