Skip to content

Building error with macOS Big Sur (11.0.1) (2346) #1204

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
GalacticEmperor1 opened this issue Feb 12, 2023 · 0 comments
Closed

Building error with macOS Big Sur (11.0.1) (2346) #1204

GalacticEmperor1 opened this issue Feb 12, 2023 · 0 comments
Labels
bug Not working as intended macOS

Comments

@GalacticEmperor1
Copy link
Collaborator

Issue №2346 opened by Bodanor at 2020-11-19 21:01:49

Environment:
OS : macOS Big Sur 11.0.1 Build (20B29)
Pygame : 2.0.0
Python : 3.9, tried also with 3.8

Current behavior:
Build error when installing from pip3

Steps to reproduce:

  1. sudo pip3 install pygame

Stack trace/error output/other error logs

sudo pip3.9 install pygame             
WARNING: The directory '/Users/chris/Library/Caches/pip' or its parent directory is not owned or is not writable by the current user. The cache has been disabled. Check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting pygame
  Downloading pygame-2.0.0.tar.gz (5.5 MB)
     |████████████████████████████████| 5.5 MB 4.0 MB/s 
    ERROR: Command errored out with exit status 1:
     command: /usr/local/opt/[email protected]/bin/python3.9 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/tmp/pip-install-3y9r_p_g/pygame/setup.py'"'"'; __file__='"'"'/private/tmp/pip-install-3y9r_p_g/pygame/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /private/tmp/pip-pip-egg-info-hxgx9bow
         cwd: /private/tmp/pip-install-3y9r_p_g/pygame/
    Complete output (27 lines):
    
    
    WARNING, No "Setup" File Exists, Running "buildconfig/config.py"
    Using Darwin configuration...
    
    /bin/sh: sdl2-config: command not found
    /bin/sh: sdl2-config: command not found
    /bin/sh: sdl2-config: command not found
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/private/tmp/pip-install-3y9r_p_g/pygame/setup.py", line 318, in <module>
        buildconfig.config.main(AUTO_CONFIG)
      File "/private/tmp/pip-install-3y9r_p_g/pygame/buildconfig/config.py", line 221, in main
        deps = CFG.main(**kwds)
      File "/private/tmp/pip-install-3y9r_p_g/pygame/buildconfig/config_darwin.py", line 131, in main
        [DependencyProg('SDL', 'SDL_CONFIG', 'sdl2-config', '2.0', ['sdl'])],
      File "/private/tmp/pip-install-3y9r_p_g/pygame/buildconfig/config_unix.py", line 39, in __init__
        self.ver = config[0].strip()
    IndexError: list index out of range
    
    ---
    For help with compilation see:
        https://www.pygame.org/wiki/MacCompile
    To contribute to pygame development see:
        https://www.pygame.org/contribute.html
    ---
    
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

Does someone else have this problem ?

I've tried installing SDL2 with homebrew, and I got another error but It still don't want to build it. So yeah there is bug when building it.


Comments

# # MyreMylar commented at 2020-11-21 12:19:38

This looks like it didn't download the wheel for pygame 2.0.0 from pip so it tries to build from source. I assume the source build didn't work because some/all of the dependencies were missing.

I wonder if the command:

sudo pip3.9 install pygame

doesn't work and you actually just need:

sudo pip3 install pygame

?


# # Bodanor commented at 2020-11-21 14:15:20

This looks like it didn't download the wheel for pygame 2.0.0 from pip so it tries to build from source. I assume the source build didn't work because some/all of the dependencies were missing.

I wonder if the command:

sudo pip3.9 install pygame

doesn't work and you actually just need:

sudo pip3 install pygame

?

Yeah actually with Big Sur, Apple has moved some dependencies on other locations so yeah building from source doesn't work. I tried both with pip3 and pip3.9


# # MyreMylar commented at 2020-11-21 14:30:31

looks like this is a bug with pip and mac wheels, see:

numpy/numpy#17784 and pypa/packaging#319

pip looks for a macosx_11 wheel and doesn't try the macosx_10_9 wheel even though it should. So for now, until the bug in pip is fixed it looks like the easiest solution is to manually download the correct 10_9 wheel for your platform and rename it to 11.

Link:

https://files.pythonhosted.org/packages/94/da/60c4cfa05c51928bbc7954fc33750e0ae16dd3794e9c4b797ff7b051faf8/pygame-2.0.0-cp39-cp39-macosx_10_9_intel.whl

then rename to:

pygame-2.0.0-cp39-cp39-macosx_11_0_intel.whl

and try and manually install the wheel with:

pip install pygame-2.0.0-cp39-cp39-macosx_11_0_intel.whl

from the directory with the wheel file in it. See if that works.


# # Bodanor commented at 2020-11-21 16:26:57

Thank you it worked as expected !


# # TrueBlue96 commented at 2021-01-02 16:21:17

This workaround doesn't work for M1 macs.


# # MyreMylar commented at 2021-01-02 17:48:11

It sounds like this bug was fixed in the latest version of pip so I would make sure you update the version of pip you are using to 20.3.3.


# # illume commented at 2021-01-02 18:07:06

Cool! Good to know. Let's close this now then.

(feel free to comment here if the new pip is still not working, and we can open it again)


# # TrueBlue96 commented at 2021-01-04 01:22:00

I installed the latest version of pip and I'm still unable to install
pygame.

Specs:
Apple M1 MBP
Big Sur 11.0.1

Sincerely,

Brittany Price

On Sat, Jan 2, 2021 at 1:07 PM René Dudfield [email protected]
wrote:

Cool! Good to know. Let's close this now then.

(feel free to comment here if the new pip is still not working, and we can
open it again)


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<pygame/pygame#2346 issuecomment-753510192>, or
unsubscribe
https://github.com/notifications/unsubscribe-auth/ALNNZECDM22YF3SH7M5HWDLSX5OFPANCNFSM4T35LFEA
.


# # ghost commented at 2021-01-06 02:22:31

I am reoppening this because it dosen't seem to be 100% fixed yet...

@brittlizprice You say the fix dosen't work on M1 macs. Is it still not installing the wheel and trying to compile (and failing)?


# # TrueBlue96 commented at 2021-01-07 20:24:39

Yes. When I try to install pygame I get a compiler error. I wasn't able to install the wheel file either.
Image 1-3-21 at 8 19 PM


# # Endogen commented at 2021-01-12 21:27:07

Also can't install on MacBook Pro M1 with Python 3.9.1

sudo -H python3 -m pip install -U pygame --user
Collecting pygame
  Downloading pygame-2.0.1.tar.gz (5.5 MB)
     |████████████████████████████████| 5.5 MB 1.2 MB/s
    ERROR: Command errored out with exit status 1:
     command: /opt/homebrew/opt/[email protected]/bin/python3.9 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/tmp/pip-install-oxsdbivr/pygame_2f9b4dc117f04901b27c382cdaf8275d/setup.py'"'"'; __file__='"'"'/private/tmp/pip-install-oxsdbivr/pygame_2f9b4dc117f04901b27c382cdaf8275d/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /private/tmp/pip-pip-egg-info-460u4d1_
         cwd: /private/tmp/pip-install-oxsdbivr/pygame_2f9b4dc117f04901b27c382cdaf8275d/
    Complete output (27 lines):


    WARNING, No "Setup" File Exists, Running "buildconfig/config.py"
    Using Darwin configuration...

    /bin/sh: sdl2-config: command not found
    /bin/sh: sdl2-config: command not found
    /bin/sh: sdl2-config: command not found
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/private/tmp/pip-install-oxsdbivr/pygame_2f9b4dc117f04901b27c382cdaf8275d/setup.py", line 318, in <module>
        buildconfig.config.main(AUTO_CONFIG)
      File "/private/tmp/pip-install-oxsdbivr/pygame_2f9b4dc117f04901b27c382cdaf8275d/buildconfig/config.py", line 221, in main
        deps = CFG.main(**kwds)
      File "/private/tmp/pip-install-oxsdbivr/pygame_2f9b4dc117f04901b27c382cdaf8275d/buildconfig/config_darwin.py", line 131, in main
        [DependencyProg('SDL', 'SDL_CONFIG', 'sdl2-config', '2.0', ['sdl'])],
      File "/private/tmp/pip-install-oxsdbivr/pygame_2f9b4dc117f04901b27c382cdaf8275d/buildconfig/config_unix.py", line 39, in __init__
        self.ver = config[0].strip()
    IndexError: list index out of range

    ---
    For help with compilation see:
        https://www.pygame.org/wiki/MacCompile
    To contribute to pygame development see:
        https://www.pygame.org/contribute.html
    ---

    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

# # Ropuh commented at 2021-01-15 09:11:52

Mac mini M1 also I can't install pygame:
`
rob@Mac-Robert ~ % sudo -H pip3 install pygame
Password:
Collecting pygame
Downloading pygame-2.0.1.tar.gz (5.5 MB)
|████████████████████████████████| 5.5 MB 1.4 MB/s
ERROR: Command errored out with exit status 1:
command: /Library/Frameworks/Python.framework/Versions/3.9/bin/python3.9 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/tmp/pip-install-0b2nsb6v/pygame_4ffe8e44583c4264a7fd2d35574ae907/setup.py'"'"'; file='"'"'/private/tmp/pip-install-0b2nsb6v/pygame_4ffe8e44583c4264a7fd2d35574ae907/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' egg_info --egg-base /private/tmp/pip-pip-egg-info-uixh66ml
cwd: /private/tmp/pip-install-0b2nsb6v/pygame_4ffe8e44583c4264a7fd2d35574ae907/
Complete output (27 lines):

WARNING, No "Setup" File Exists, Running "buildconfig/config.py"
Using Darwin configuration...

/bin/sh: sdl2-config: command not found
/bin/sh: sdl2-config: command not found
/bin/sh: sdl2-config: command not found
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/private/tmp/pip-install-0b2nsb6v/pygame_4ffe8e44583c4264a7fd2d35574ae907/setup.py", line 318, in <module>
    buildconfig.config.main(AUTO_CONFIG)
  File "/private/tmp/pip-install-0b2nsb6v/pygame_4ffe8e44583c4264a7fd2d35574ae907/buildconfig/config.py", line 221, in main
    deps = CFG.main(**kwds)
  File "/private/tmp/pip-install-0b2nsb6v/pygame_4ffe8e44583c4264a7fd2d35574ae907/buildconfig/config_darwin.py", line 131, in main
    [DependencyProg('SDL', 'SDL_CONFIG', 'sdl2-config', '2.0', ['sdl'])],
  File "/private/tmp/pip-install-0b2nsb6v/pygame_4ffe8e44583c4264a7fd2d35574ae907/buildconfig/config_unix.py", line 39, in __init__
    self.ver = config[0].strip()
IndexError: list index out of range

---
For help with compilation see:
    https://www.pygame.org/wiki/MacCompile
To contribute to pygame development see:
    https://www.pygame.org/contribute.html
---

----------------------------------------

ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
rob@Mac-Robert ~ %
`


# # robertpfeiffer commented at 2021-01-15 10:48:33

@Ropuh @Endogen @brittlizprice so do any of you actually have SDL2 installed?

I assume you do not, and the problem is just that there are no pre-built binary wheels for macos 11 on ARM.
Is there a pre-built SDL2 installer for mac os 11 on ARM? Do the downloads on libSDL.org work on ARM?

In the worst case, you have to compile SDL2 from source.

Maybe we could draft one of you into installing SDL2 and building a wheel from source...


# # rajatyagi commented at 2021-01-15 16:08:41

I have downloaded the latest version of sdl (2.0.14) using the command :
brew install sdl2 sdl2_gfx sdl2_image sdl2_mixer sdl2_net sdl2_ttf
but I am still facing the same issue on my M1 MacBook Air.
@robertpfeiffer how do we go about building the wheel from source?


# # ankith26 commented at 2021-01-15 16:25:02

First make sure pip is on the latest version.
Then try this command
pip3 install https://github.com/pygame/pygame
This is going to make pip install the latest version from github, which is a few commits ahead of v2.0.1
The reason I’m suggesting that, rather than installing 2.0.1, is just to eliminate any pip related errors that happen while finding the right Mac wheels. That command will force pip to build pygame from source, and if your dependencies are all right, it’s gonna hopefully work :)


# # robertpfeiffer commented at 2021-01-15 17:57:44

@rajatyagi I would try to find where sdl2-config is installed on your system and add that to $PATH, and barring that, find out where brew installed the SDL2 libraries and header files and report back here.

Based on what I know about homebrew (and I want to make it clear, I do not have an M1 mac or access to privileged information, all this is based on 5 minutes of googling), sdl2-config might be installed into /opt/homebrew/bin, but sdl2 can be installed on arm64 mac os with homebrew: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/sdl2.rb

So what you probably need to do is:

  1. make sure that you installed python/pip via the same method as SDL
  2. find where your install has put SDL2-config, add that location to your PATH if necessary like so: `export PATH="/opt/homebrew/bin:$PATH"
  3. install pygame via pip (be sure to use the right python install here, if you got SDL via macports or brew, use the python from macports or brew to install pygame)
  4. report back here

I wouldn't want to hardcode /opt/homebrew/bin inside setup.py case python is installed in /Library/Frameworks or /usr/local or /opt/ports


# # robertpfeiffer commented at 2021-01-15 18:05:24

does installing SDL2 in /Library/Frameworks even install the sdl2-config command line program?


# # rajatyagi commented at 2021-01-15 22:21:25

The issue is resolved.
@robertpfeiffer you were right, I just followed the directions given by you
I found the SDL2-config file at:
/usr/local/bin/sdl2-config .
I added it to my path by:
export PATH=$PATH:/usr/local/bin/sdl2-config
finally I linked my python 3.9 with Homebrew using:
brew link [email protected]
then used the pip command to install pygame:
pip3 install pygame
Thanks for all the help!!


# # robertpfeiffer commented at 2021-01-16 10:08:21

@rajatyagi It should be the directory, not the program itself. Are you telling me /usr/local/bin was not part of $PATH already on mac os 11? Or did brew link [email protected] link python into /usr/local so you invoked the right pip?

In any case, if you get it to install with pip on one mac, you can run this:

git clone https://github.com/pygame/pygame.git
cd pygame
python3.9 setup.py -config -auto -sdl2
python3.9 setup.py bdist_wheel

to get a .whl file in the dist/ directory that can be installed on another mac (with the same OS and CPU arch) with pip.

Before more people post about their homebrew setup: This is not a homebrew/macports/autoconf support forum. As far as I can tell, the arm64 mac os currently has no binary wheel support, but that is a different issue from this one that was posted about x86.

We will may to open another issue for automatically binary wheels on mac os 11 with arm64 (Can we cross-compile? Does the CI run mac os?), but it seems to me that there is no problem actually compiling pygame if you have set up your system right.


# # TrueBlue96 commented at 2021-01-17 09:35:05

I got this error. Should I uninstall & reinstall pip and pygame? Trying to install the homebrew (cannot unpack error) and I also tried Robert's suggestion and got an out of range error.

Image 1-17-21 at 4 33 AM

Image 1-17-21 at 4 36 AM


# # robertpfeiffer commented at 2021-01-17 16:29:20

@brittlizprice In order to compile pygame, you need to install sdl2. You do not need to "reinstall pip" (I am probably misreading this. You can just use pip to upgrade pip. I do not think you need to uninstall and reinstall pygame via pip either). Right now, there are no binary pip wheels for pygame in arm64 mac os 11, so you have to compile your own sdl2 in order to compile pygame. Since there are no binary wheels for pygame yet, pip is attempting to compile pygame, but doesn't find the development files for SDL2.

You can either download the source from libSDL2.org, or install via homebrew. Macports and fink might also work, I don't know. I haven't used a mac in a decade. Compilation and installation of SDL2 development files needs to be done before you run pip install pygame.

In any case, the original bug reported here has been resolved. This is not a mac OS help forum, but a bug tracker.

I have created an issue with a task list for the mac os build situation.


# # TrueBlue96 commented at 2021-01-17 18:46:18

@robertpfeiffer I know it's not a macOS help forum, I wasn't entirely sure about how the
solution worked. I don't use terminal commands often. You don't have to be a jerk about it because you didn't get a DTK in June and make the transition earlier. Looking below clearly the issue isn't resolved. Users shouldn't have to go through this much trouble to use a plugin. For now I'll use something else.

On Sun, Jan 17, 2021, 11:29 AM robertpfeiffer [email protected]
wrote:

@brittlizprice https://github.com/brittlizprice In order to compile
pygame, you need to install sdl2. You do not need to "reinstall pip" (I am
probably misreading this. You can just use pip to upgrade pip. I do not
think you need to uninstall and reinstall pygame via pip either). Right
now, there are no binary pip wheels for pygame in arm64 mac os 11, so you
have to compile your own sdl2 in order to compile pygame. Since there are
no binary wheels for pygame yet, pip is attempting to compile pygame, but
doesn't find the development files for SDL2.

You can either download the source from libSDL2.org, or install via
homebrew. Macports and fink might also work, I don't know. I haven't used a
mac in a decade. Compilation and installation of SDL2 development files
needs to be done before you run pip install pygame.

In any case, the original bug reported here has been resolved. This is not
a mac OS help forum, but a bug tracker.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<pygame/pygame#2346 issuecomment-761839471>, or
unsubscribe
https://github.com/notifications/unsubscribe-auth/ALNNZEBNBBLCFBZ3SP6NZSDS2MF65ANCNFSM4T35LFEA
.


# # BUCKFAE commented at 2021-01-18 12:35:07

The issue is resolved.
@robertpfeiffer you were right, I just followed the directions given by you
I found the SDL2-config file at:
/usr/local/bin/sdl2-config .
I added it to my path by:
export PATH=$PATH:/usr/local/bin/sdl2-config
finally I linked my python 3.9 with Homebrew using:
brew link [email protected]
then used the pip command to install pygame:
pip3 install pygame
Thanks for all the help!!

Works on my machine as well (MacBook Pro M1).

Adding sdl2 to the path was not required in my case, it worked out of the box after using brew to install sdl2.

However I still got an error installing pygame which was fixed by
brew reinstall freetype pkg-config


# # ryanrudes commented at 2021-03-04 16:21:32

Running brew reinstall freetype pkg-config worked for me, too


# # Maxlanglet commented at 2021-03-04 19:53:31

Hello everybody, despite all of your help I couldn't install pygame. Maybe the reason is that my version of python is from mini forge and miniconda ? I don't know really since it usually doesn't cause problems. I can add that the sdl2-config file was not un /usr/local/bin but in something like /opt/homebrew/Cellar/..


# # johnson7788 commented at 2021-03-23 08:05:38

@rajatyagi It should be the directory, not the program itself. Are you telling me /usr/local/bin was not part of $PATH already on mac os 11? Or did brew link [email protected] link python into /usr/local so you invoked the right pip?

In any case, if you get it to install with pip on one mac, you can run this:

git clone https://github.com/pygame/pygame.git
cd pygame
python3.9 setup.py -config -auto -sdl2
python3.9 setup.py bdist_wheel

to get a .whl file in the dist/ directory that can be installed on another mac (with the same OS and CPU arch) with pip.

Before more people post about their homebrew setup: This is not a homebrew/macports/autoconf support forum. As far as I can tell, the arm64 mac os currently has no binary wheel support, but that is a different issue from this one that was posted about x86.

We will may to open another issue for automatically binary wheels on mac os 11 with arm64 (Can we cross-compile? Does the CI run mac os?), but it seems to me that there is no problem actually compiling pygame if you have set up your system right.

Same error, I am Mac M1, i do brew reinstall freetype pkg-config and build as your step, it works now. thanks!


# # Ozzymandias0 commented at 2021-06-05 22:39:25

The issue is resolved.
@robertpfeiffer you were right, I just followed the directions given by you
I found the SDL2-config file at:
/usr/local/bin/sdl2-config .
I added it to my path by:
export PATH=$PATH:/usr/local/bin/sdl2-config
finally I linked my python 3.9 with Homebrew using:
brew link [email protected]
then used the pip command to install pygame:
pip3 install pygame
Thanks for all the help!!

Works on my machine as well (MacBook Pro M1).

Adding sdl2 to the path was not required in my case, it worked out of the box after using brew to install sdl2.

However I still got an error installing pygame which was fixed by
brew reinstall freetype pkg-config

Thanks. This worked on macbook air m1


# # Raumss commented at 2021-07-05 16:30:06

Here is my solution on Apple Silicon MacBook:
brew install sdl2 sdl2_gfx sdl2_image sdl2_mixer sdl2_net sdl2_ttf pkg-config
pip3 install pygame --pre


# # serh11kalinin commented at 2021-07-14 03:28:08

Here is my solution on Apple Silicon MacBook:
brew install sdl2 sdl2_gfx sdl2_image sdl2_mixer sdl2_net sdl2_ttf pkg-config
pip3 install pygame --pre

@Raumss big big thanks! worked for me!!!


# # Vickko commented at 2021-07-27 16:13:44

Running brew reinstall freetype pkg-config worked for me, too

It worked for me. Thanks!


# # christianblandford commented at 2021-07-28 17:54:42

Here is my solution on Apple Silicon MacBook:
brew install sdl2 sdl2_gfx sdl2_image sdl2_mixer sdl2_net sdl2_ttf pkg-config
pip3 install pygame --pre

Worked for me too on M1 Macbook Pro! Thanks so much.


# # aleolux commented at 2021-10-14 01:49:54

Here is my solution on Apple Silicon MacBook:
brew install sdl2 sdl2_gfx sdl2_image sdl2_mixer sdl2_net sdl2_ttf pkg-config
pip3 install pygame --pre

Thank you!!


# # Laenpo commented at 2023-02-09 23:14:14

export PATH=$PATH:/usr/local/bin/sdl2-config
pip3 install pygame

I only used these two commands
It really works!
Thanks for the help!

@GalacticEmperor1 GalacticEmperor1 added bug Not working as intended macOS labels Feb 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Not working as intended macOS
Projects
None yet
Development

No branches or pull requests

1 participant