Skip to main content
Join the official 2020 Python Developers SurveyStart the survey!

Python CFFI bindings for Raylib

Project description

Python Bindings for Raylib 2.6

New CFFI API static bindings. Faster, fewer bugs and easier to maintain than ctypes.


RetroWar: 8-bit Party Battle is out now. Defeat up to 15 of your friends in a tournament of 80s-inspired retro mini games.


Windows 10 (64 bit): Python 3.6 - 3.8

MacOS: Python 3.6 - 3.8

Linux (Ubuntu 16.04+): Python 3.6 - 3.8

We distribute a statically linked Raylib library, install from Pypi.

pip3 install raylib

If you're a different version of Python, or a Linux with incompatible libraries then you can either use the dynamic binding only or else you will have to build from source. Download, compile and install Raylib 2.6 then

cd raylib/static



Goal is make usage as similar to the original C as CFFI will allow. There are a few differences you can see in the examples. See and examples/*.py for how to use.

from raylib.static import *

InitWindow(800, 450, b"Hello Raylib")

camera ="struct Camera3D *", [[18.0, 16.0, 18.0], [0.0, 0.0, 0.0], [0.0, 1.0, 0.0], 45.0, 0])
SetCameraMode(camera[0], CAMERA_ORBITAL)

while not WindowShouldClose():
    DrawGrid(20, 1.0)
    DrawText(b"Hellow World", 190, 200, 20, VIOLET)


Wrapper around the static bindings. Makes the names snakecase and converts strings to bytes automatically. See

from raylib.pyray import PyRay
from raylib.colors import *

pyray = PyRay()

pyray.init_window(800, 450, "Hello Pyray")

camera = pyray.Camera3D([18.0, 16.0, 18.0], [0.0, 0.0, 0.0], [0.0, 1.0, 0.0], 45.0, 0)
pyray.set_camera_mode(camera, pyray.CAMERA_ORBITAL)

while not pyray.window_should_close():
    pyray.draw_grid(20, 1.0)
    pyray.draw_text("Hello world", 190, 200, 20, VIOLET)


In addition to the API static bindings we have CFFI ABI dynamic bindings in order to avoid the need to compile a C extension module. There have been some weird failures with dynamic bindings and ctypes bindings before and often the failures are silent so you dont even know. Also the static bindings should be faster. Therefore I recommend the static ones...

BUT the dynamic bindings have the big advantage that you don't need to compile anything to install. You just need a Raylib DLL, which we supply for Windows/Mac/Linux.

See for how to use.


A simplified API for Raylib for use in education and to enable beginners to create 3d games

Platforms tested

  • (MacOS 10.12.6 - Python 3.7)
  • (Ubuntu 18.04 LTS - Python 3.6)
  • Debian 10 - Python 3.7
  • Windows 10 (64 bit) - Python 3.8


  • converting more examples from C to python
  • testing and building on more platforms
  • sorting out binary wheel distribution for Mac/Win and compile-from-source distributtion for Linux
  • dealing with conversions to pointers in PyRay automatically

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for raylib, version 2.6.0
Filename, size File type Python version Upload date Hashes
Filename, size raylib-2.6.0-py3-none-any.whl (13.2 MB) File type Wheel Python version py3 Upload date Hashes View
Filename, size raylib-2.6.0.tar.gz (13.1 MB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page