{"id":26810,"library":"box2d","title":"PyBox2D","description":"Python bindings for Box2D, a 2D physics engine. Version 2.3.10 is the latest. Releases are infrequent; the library is stable but in maintenance mode.","status":"maintenance","version":"2.3.10","language":"python","source_language":"en","source_url":"https://github.com/pybox2d/pybox2d","tags":["physics","2d","game-development","simulation"],"install":[{"cmd":"pip install box2d","lang":"bash","label":"Install from PyPI"}],"dependencies":[],"imports":[{"note":"The top-level module is 'Box2D' (capital B, capital D).","symbol":"Box2D","correct":"from Box2D import b2World"},{"note":"Package name is 'box2d' (lowercase), but the module is 'Box2D' (capital letters).","wrong":"from box2d import b2World","symbol":"b2World","correct":"from Box2D import b2World"}],"quickstart":{"code":"from Box2D import b2World, b2Vec2, b2BodyDef, b2_dynamicBody, b2CircleShape, b2FixtureDef\nimport math\n\nworld = b2World(gravity=b2Vec2(0, -10))\nbody_def = b2BodyDef()\nbody_def.type = b2_dynamicBody\nbody_def.position.Set(0, 10)\nbody = world.CreateBody(body_def)\ncircle = b2CircleShape(radius=1)\nfixture_def = b2FixtureDef(shape=circle, density=1, friction=0.3)\nbody.CreateFixture(fixture_def)\n\nfor i in range(60):\n    world.Step(1/60, 6, 2)\n    print(body.position.y)","lang":"python","description":"Creates a simple falling circle simulation."},"warnings":[{"fix":"Use 'from Box2D import ...' instead of 'from box2d import ...'.","message":"The import module is 'Box2D' (capital B and D), not 'box2d' (lowercase). The PyPI package name is 'box2d' but the module name uses CamelCase.","severity":"gotcha","affected_versions":"all"},{"fix":"Use Python 3.6 or newer.","message":"Python 2 is no longer supported. Ensure you are using Python 3.","severity":"deprecated","affected_versions":"2.3.10+"},{"fix":"Use body.position.Set(x, y) before creation or body.SetTransform(b2Vec2(x,y), angle) after creation.","message":"Setting body position using the 'position' attribute after creation may not work; use SetTransform() instead.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"from Box2D import ...","cause":"Importing from 'box2d' (lowercase) but the correct module is 'Box2D'.","error":"ModuleNotFoundError: No module named 'box2d'"},{"fix":"Reinstall via 'pip install --upgrade box2d' and verify import using 'import Box2D; print(dir(Box2D))'.","cause":"Usually due to a broken installation or mismatched package versions; also can happen if importing from 'Box2D' but the library is not properly installed.","error":"AttributeError: module 'Box2D' has no attribute 'b2World'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}