简体   繁体   中英

Installing and using RayLib in macOS 12.2.1 with Python 3.10

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.

My macOS is using an  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 
- 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  pip and then install raylib 

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM