簡體   English   中英

在帶有 Python 3.10 的 macOS 12.2.1 中安裝和使用 RayLib

[英]Installing and using RayLib in macOS 12.2.1 with Python 3.10

我正在使用帶有 Python 3.10 的 macOS 12.2.1,我正在嘗試安裝 Raylib Python CFFI 3.7 或更高版本,但每當我運行python3 -m pip install raylib命令或pip3 install raylib命令時,我都會收到以下錯誤:

  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]

我嘗試了幾件事來解決這個問題,但沒有運氣。

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.

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM