0

I am using a macOS 12.2.1 with Python 3.10 and I am trying to install Raylib Python CFFI 3.7 or higher but whenever I run the python3 -m pip install raylib command or the pip3 install raylib command but I keep getting the error below:

  generating cffi module 'build/temp.macosx-10.9-universal2-3.10/raylib._raylib_cffi.c'
  building 'raylib._raylib_cffi' extension
  build/temp.macosx-10.9-universal2-3.10/raylib._raylib_cffi.c:570:14: fatal error: 'raylib.h' file not found
      #include "raylib.h"
               ^~~~~~~~~~
  1 error generated.
  error: command '/usr/bin/clang' failed with exit code 1
  [end of output]

I tried several things to solve this issue but no luck.

2 Answers2

0
My macOS is using an Apple M1 Max chip and it looks like my macOS is having compilation issues with raylib.

If you have an M1 based Mac, you should create a Rosetta based terminal and work within that terminal by following these steps below [ONLY FOR macOS M1].

- Uninstall all the packages I previously had installed by executing python3 -m pip uninstall [package]
- Locate the Terminal application within the Utilities folder (Finder > Go menu > Utilities)
- Select Terminal.app and right-click on it, then choose “Duplicate”.
- Rename the duplicated Terminal app something obvious and distinct, like ‘Rosetta Terminal’.
- Now select the freshly renamed ‘Rosetta Terminal’ app and right-click and choose “Get Info” (or hit Command+i)
- Check the box for “Open using Rosetta”, then close the Get Info window.
- Run the “Rosetta Terminal” as usual, which will fully support Homebrew and other x86 command line apps.

- In the “Rosetta Terminal”, first ensure pip is upgraded python3 -m pip install --upgrade pip and then install raylib python3 -m pip install raylib

- Then you should be able to run your raylib based python game.
0

Details and solutions in this github issue, https://github.com/electronstudio/raylib-python-cffi/issues/65#issuecomment-1222484840

brew install raylib
pip3 install --no-binary raylib --upgrade --force-reinstall raylib

This worked for me on macos 13.1, M2 Macbook Air.

Mathnode
  • 965
  • 1
  • 9
  • 15