Fixing setup.py bdist_wheel for pygame error – while trying to install pygame with pip

setup.py bdist_wheel for pygame error – while trying to install pygame with pip is an error which occurs when the dependencies required for pygame to work properly are missing.

In this blog post I will get into what occurs when you get this error and how we can get rid of it with a main solution, I will also try to present other solutions if possible.

Exploring the Error : setup.py bdist_wheel for pygame error – while trying to install pygame with pip

This is an error which occurs when the dependencies required for pygame to work properly are missing.

Your error message should match the one bellow. We want to avoid confusion by not mixing between error messages.

                                                                       #
xcode-select: error: command line tools are already installed, use "Software Update" to install updates
Running setup.py bdist_wheel for pygame ... error
                                                                       #

Bellow I make my best attempt at solving the error and present multiple possible fixes.

Solution : install all the pygame dependecies using brew install sdl_ttf sdl_mixer portmidi sdl_image sdl

The error occurs because we have not installed the dependencies required for pygame to work.

These are the dependencies needed by pygame, portmidi, sdl_ttf, sdl_mixer, sdl and sdl_image.

To solve the problem we can install the dependencies one by one, like in the commands bellow.

                                                                       #
pip install sdl_image # This is a mistake, do not use pip to install the dependencies
                                                                       #

Do not use pip to install the dependencies use brew instead.

                                                                       #
brew install sdl_mixer
brew install sdl_ttf
brew install portmidi
brew install sdl
brew install sdl_image
                                                                       #

You can also use only one command which installs all the dependencies at once.

                                                                       #
brew install sdl_ttf sdl_mixer portmidi sdl_image sdl
                                                                       #

Finally, after all the dependencies are installed, use pip to install pygame

                                                                       #
pip install pygame
                                                                       #

Installing all the pygame dependencies should be enough to solve the problem.

I hope one of these commands helped you solve the issue, congratulations If the issue is gone.

Summing-up

Finally, we are at the end of this article, I hope this article has been helpful, I hope you solved your problem, coding can be hard when you have a lot of confusing errors here and there.

Thank you for reading, keep learning and keep coding, cheers. If you want to learn more about Python, please check out the Python Documentation : https://docs.python.org/3/