pygame / pygame

🐍🎮 pygame (the library) is a Free and Open Source python programming language library for making multimedia applications like games built on top of the excellent SDL library. C, Python, Native, OpenGL.

Home Page:https://www.pygame.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Pygame not compatible with MacOS Mojave

adam-hotait opened this issue · comments

Edit: pygame 2 works nicely with Mac now.

Use python3 -m pip install pygame


SDL discussion and bug report:

Homebrew issue is here: Homebrew/homebrew-core#33016


As discussed on this stackoverflow post, it seems that pygame is not compatible with MacOS Mojave, the latest version of MacOS.

Information on tests done can be found on the post. It might be a conflict with the graphical overlay managing its new Dark Mode.

commented

Same issue here, running

python -m pygame.examples.aliens

opens a window, sounds and music can be heard, but black screen surface all the time.

Works without a problem, on a fresh Mojave install, with Python 3.7.0 from Miniconda, the version of PyGame reported is 1.9.4 .

screen shot 2018-10-21 at 7 06 20 am

Confirmed, it seems to work with miniconda

Sorry if this is not the right place to post this, but is there a fix for this other than using miniconda? if not where can I follow to be aware when a fix is in place? I was really interested in picking up pygame but I might just go back to libGDX until this is working on Mojave!

The bug is reproduced with python 3.7.1 + pygame 1.9.4
But isn't reproduced with python 3.6.5 + pygame 1.9.4

As a work-around I created a virtualenv for 3.6.5 version

Can reproduce this using python 3.7.0, 3.6.6 and 3.6.5 with both virtualenv and venv, so downgrading python didn't seem to help.

All Python versions mentioned above were installed via pyenv, the pygame version was always 1.9.4. Interestingly, trying it with Python 3.5.6 failed during installation of pygame with src/scrap.c:27:10: fatal error: 'SDL.h' file not found, though I don't know if that's relevant.

I encounter this issue with python 3.6.5 + pygame 1.9.4 and python 3.7.1 + pygame 1.9.4
I do not encounter the issue with python 3.7.0 + pygame 1.9.4.
Framerate increases substantially whether it works or not but running app in low resolution.
I wonder why it would start working by switching up the 3.7.0, but then stop working again switching up to 3.7.1.

the miniconda suggestion didn't work for me; what i had to do was to download the pkg file from:

https://www.python.org/downloads/release/python-370/
for python 3.7.0
and install

verify:
python3 --version
should be 3.7.0

then:
pip3 install pygame (installed 1.9.4)

then all worked.

Rolling back to python 3.7.0 and reinstalling pygame worked for me, but now the second problem is that display.update() became incredibly slow. The saucers in the aliens game in the examples move several times slower than before. I've timed display.update() and it seems that it takes a constant amount of time to redraw the screen regardless of how many rectangles you pass to it. Even passing a tiny 10x10 rectangle takes more than 200 ms to update.

Edit: The solution given below fixed this problem for me.
https://stackoverflow.com/questions/31685936/pygame-application-runs-slower-on-mac-than-on-pc

As of Python 3.7.2 the issue is unresolved.

As of macOS Mojave 10.14.2 and Python 3.7.2 the issue is unresolved.

I followed the advice up above and downloaded the official macOS x64 installer package of Python 3.7.2 from the official python page, and then used:

pip3 install pygame

And now I'm seeing the window contents again. (macOS 10.14.1, going to update to 10.14.2 and verify all else is fine).

Looking at the Pygame 1.9.5 milestone...it states you are waiting for an SDL fix but it looks like this was fixed back SDL 2.0.8 (Current SDL 2.0.9) - https://bugzilla.libsdl.org/show_bug.cgi?id=4272

Im guessing that you are waiting for the 1.2.x historic version of SDL to be patched though?

@DanielJenkyn

If you download the official macOS x64 installer package of Python 3.7.2 from the official python page and then pip3 install pygame it works.

2 is using SDL2, 1.9.5 will use SDL1.

@illume Just to point out, using python 3.7.2 and pip3 pygame works great...However the Homebrew version of python 3.7.2 results in the blank game window using the same version of pygame

Thanks @DanielJenkyn I updated the issue. I'm going to upgrade my mac in the coming days, so will be able to look into it then.

As I understand, due to closed state of homebrew issue, they are not going to fix it, yes?

So the solution is to remove homebrew python3.7.2 and use official installer from python website?

My operating system is macOS Mojave and I am experiencing the same thing. I've configured my development environment using Pyenv 1.2.9. On Pyenv, I've install Python 3.7.2 and Pygame 1.9.4. Python was installed using Pyenv and Pygame was installed using pip.

When running my code snippet, I get this screen:

screen shot 2019-01-18 at 8 16 10 pm

This error also occurs when running the Pygame example, python3 -m pygame.examples.aliens.

When can we expect Pygame to be compatible with Mojave?

NOTE: I've tried Python 3.7.2, 3.7.0, 3.6.5, and 3.6.1.

@ChaseHardin I suspect installing 3.7.2 via official .dmg installer from python.org will do the trick. Did not try it myself, though, yet

@ChaseHardin Can you try pulling the latest from source/github? While I've been testing the 1.9.4 build has never worked on MacOS (other than Mojave) for me, BUT when I build -- even 1.9.4 from source, I have no issue.

This top section of the page -- are updates that I made -- and should work for you.
https://www.pygame.org/wiki/MacCompile

@idchlife I'd like to continue using Pyenv so that I can have my own virtual environment. Any recommendations if I use Pyenv?

@markph0204 how would I pull the latest from source/github? I installed Pygame using the pip3 installer. Also to note, I'm using MacOS Mojave.

I'm seeing a lot of reference to mercurial. Is that something Python/Pygame needs to run?

@ChaseHardin You do not need mercurial -- you need git and it comes installed on MacOS by default. To get the latest from pygame, you can git clone https://github.com/pygame/pygame.git then build it local or follow Step 5 on the page I shared: https://www.pygame.org/wiki/MacCompile

Also you can use pyenv -- just activate the environment you want before you pip install.

Good luck!

Unfortunately, reproduced on MacOS Mojave 10.14.2, with pyenv pythons versions: 3.7.2, 3.7.0, 3.6.8 and 3.6.5 for pygame 1.9.4 installed from pipenv. 😕

I don't want to compiling sources, installing additional pythons which could a bit make mess on my Mac or so, it should be normally available with base python interpreter.

Hope to get it fixed and released soon, now need to change computer for my Linux. 🐧

@reza-iranmanesh 's instructions worked for me:

https://www.python.org/downloads/release/python-370/
for python 3.7.0
and install

verify:
python3 --version
should be 3.7.0

then:
pip3 install pygame (installed 1.9.4)

Downloading the macOS x64 installer package of Python 3.7.0 from the official python page and then pip3 install pygame. I'm using macOS Mojave 10.14.2. I just have to use the command python3 file_url to initiate.

I'm having the same issue with pygame==1.9.4, Python==3.7.2 and macOS==10.14.2. Will look into building from source.

I had the same issue, got it to work by downgrading python to 3.6.5.

brew unlink python 
brew install --ignore-dependencies https://raw.githubusercontent.com/Homebrew/homebrew-core/f2a764ef944b1080be64bd88dca9a1d80130c558/Formula/python.rb
brew switch python 3.6.5_1
pip3 install pygame

If you already have python 3.6.5 install I guess you can just use switch.

Mojave
10.14.3
Python3
3.6.3
Pygame
1.9.4
Is working fine for me.

I have students installing and using conda to install pygame ended up work for everyone although the aliens program linked off of the Pygame.org site still doesn't work. Running other pygame programs from the Terminal works fine.

My versions:
Mojave10.14.3
Python3.6.5
Pygame1.9.4

Download python3.6.5 from python.org and install;
(Terminal: python3--> python3.6.5)
pip3 install pygame
(Terminal:
Open pycharm project and change the interpreter to 3.6.5
u see:
screenshot 2019-03-02 at 05 43 13

the miniconda suggestion didn't work for me; what i had to do was to download the pkg file from:

https://www.python.org/downloads/release/python-370/
for python 3.7.0
and install

verify:
python3 --version
should be 3.7.0

then:
pip3 install pygame (installed 1.9.4)

then all worked.

I had the same issue with macOS 10.14.3.
I followed this advice and it is work for me.
Just download the latest python package from python.org and install python. After that, pip3 install pygame

For Mojave use envirorment with Python 3.6

osx 10.14.4, pygame 1.9.5, brew sdl2, python (3.7.3, 3.6.5, 3.8-dev), asdf, pipenv - sound with empty screen surface all the time.


osx 10.14.4, brew sdl2, python 3.7.3, asdf
git clone https://github.com/pygame/pygame.git (pygame 2.0.0.dev0)
cd pygame
python setup.py -config -auto -sdl2
python setup.py install

works without a problem.

mac os 10.14.4
python 3.7.2
pygame 1.9.5

1.brew install sdl2 sdl2_gfx sdl2_image sdl2_mixer sdl2_net sdl2_ttf
2.cd python3.7.2/lib/python3.7/site-packages
3.git clone https://github.com/pygame/pygame.git
4.cd pygame
5.python setup.py -config -auto -sdl2
6.python setup.py install

UPDATE FIX: If you download the official macOS x64 installer package of Python 3.7.2 from the official python page and then pip3 install pygame it works.

* [ ]  homebrew python 3.7 still has a problem.

SDL discussion and bug report:

* https://discourse.libsdl.org/t/macos-10-14-mojave-issues/25060/8

* https://bugzilla.libsdl.org/show_bug.cgi?id=4274

Homebrew issue is here: Homebrew/homebrew-core#33016

As discussed on this stackoverflow post, it seems that pygame is not compatible with MacOS Mojave, the latest version of MacOS.

Information on tests done can be found on the post. It might be a conflict with the graphical overlay managing its new Dark Mode.

I can confirm it is true and now pygame works, such a bugger to deal with. Thanks!

@aspanoz comments worked for me.

osx 10.14.4, brew sdl2, python 3.7.3, asdf
git clone https://github.com/pygame/pygame.git (pygame 2.0.0.dev0)
cd pygame
python setup.py -config -auto -sdl2
python setup.py install

works without a problem.

Mojave 10.14.3
Python 3.7.3 (using brew install)
Pygame 2.0.0.dev1 (latest version)

Works correctly, no other version I tried did.
Side note: I use Dark Mode Theme.

Yup had to uninstall homebrew versions and install "official" package from: https://www.python.org/downloads/

If you have conda installed [1], but would like to keep your trusted homebrewed python around, here is what solved it for me:

conda create -n pygame python
conda activate pygame
pip install pygame
python -m pygame.examples.aliens

Mojave 10.14.3
Python 3.7.3 (using brew install)
Pygame 2.0.0.dev1 (latest version)

Works correctly, no other version I tried did.
Side note: I use Dark Mode Theme.

It works with Pygame 2.0.0.dev1

mac os 10.14.4
python 3.7.2
pygame 1.9.5

1.brew install sdl2 sdl2_gfx sdl2_image sdl2_mixer sdl2_net sdl2_ttf
2.cd python3.7.2/lib/python3.7/site-packages
3.git clone https://github.com/pygame/pygame.git
4.cd pygame
5.python setup.py -config -auto -sdl2
6.python setup.py install

Worked great for me, but of course you have to uninstall the broken one or it hides the git version (and on my system I have to use python3 and pip3):

pip3 uninstall pygame

FTR I have OSX 10.14.2, Python 3.7.3 (brew) and Pygame 2.0.0.dev1

UPDATE FIX: If you download the official macOS x64 installer package of Python 3.7.2 from the official python page and then pip3 install pygame it works.

This did not work for me, on MacOS 10.14.5. I've tried official Python.org .pkg installers for Python 3.5.3, 3.6.3, and 3.7.4. In each case, I uninstalled the existing Python3 app, then installed Python3 and did "pip3 install pygame" in the terminal. In all cases, pygame installs successfully, but the following code entered at an interactive python3 prompt fails to open a Pygame window:

import pygame
pygame.init()
screen = pygame.display.set_mode((300,300))

Update on my previous comment: calling pygame.display.set_mode((300,300)) a second time results in a window being shown, as expected.

commented

FWIW, I had this problem after attempting to turn on Dark mode with a plist key with the latest final 1.x release but 2.0.0.dev3 (IIRC) works great. (Is it close to final release?)

Can confirm that installing with:

# pip
pip install pygame==2.0.0.dev3

# poetry
poetry add pygame --allow-prereleases

works like a charm on Python 3.7.3 (via pyenv) + macOS Mojave.

@florimondmanca Can confirm.

On macOS Catalina, the fix for this was to run pip3 install pygame==2.0.0.dev4

Running pip3 install pygame==2.0.0.dev4 should fix this issue.

edit: dev4 was the latest dev beta at the time of writing. I'd imagine later versions would work too, and I'd recommend using those instead

Closing this because it works in pygame 2.

@florimondmanca Can confirm.

On macOS Catalina, the fix for this was to run pip3 install pygame==2.0.0.dev4

Running pip3 install pygame==2.0.0.dev4 should fix this issue.

This is solve my problem.Thank you

I also have trouble to run following with pygame on Catalina
`
import pygame
pygame.init()
screen = pygame.display.set_mode((400, 300))
done = False

while not done:
for event in pygame.event.get():
if event.type == pygame.QUIT:
done = True

pygame.display.flip()`

I get following error.

% /Users/.../Documents/Dev/Python/Playground/env/bin/python /Users/.../Documen ts/Dev/Python/Playground/game_test.py pygame 2.0.0.dev7 (SDL 2.0.10, python 3.7.1) Hello from the pygame community. https://www.pygame.org/contribute.html ERROR: pygame.macosx import FAILED ERROR: pygame.macosx import FAILED Traceback (most recent call last): File "/Users/.../Documents/Dev/Python/Playground/game_test.py", line 4, in <module> screen = pygame.display.set_mode((400, 300)) pygame.error: Video subsystem has not been initialized

I have installed following packages.
`
Package Version


pip 19.3.1
pygame 2.0.0.dev7
`

Finally get all sorted out... thank you all! :D

macOS Catalina
Version 10.15

python -V
Python 2.7.10
python3 -V
Python 3.8.0

sudo pip3 install pygame==2.0.0.dev4

pip3 list
Package       Version
------------- ----------
pip           19.3.1
pygame        2.0.0.dev4
setuptools    41.2.0

Test:
python3 -m pygame.examples.stars

Screen Shot 2019-11-16 at 7 23 44 PM

pip install pygame=2.0.0.dev4

you mean 'pip install pygame ==2.00.dev4'
it will have == instead of =

pip install pygame=2.0.0.dev4

you mean 'pip install pygame ==2.00.dev4'
it will have == instead of =

It worked for me on

MacOs Catalina 10.15.1

MacOS Catalina 10.15.2
Python 3.7.3 with below errors

pygame 2.0.0.dev4 (SDL 2.0.10, python 3.7.3)
Hello from the pygame community. https://www.pygame.org/contribute.html
Changing to FULLSCREEN
Traceback (most recent call last):
File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/runpy.py", line 193, in _run_module_as_main
"main", mod_spec)
File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/Library/Python/3.7/site-packages/pygame/examples/aliens.py", line 350, in
main()
File "/Library/Python/3.7/site-packages/pygame/examples/aliens.py", line 285, in main
pygame.display.flip()
pygame.error: Window surface is invalid, please call SDL_GetWindowSurface() to get a new surface

@29217321 Try the latest beta?

Finally get all sorted out... thank you all!
brew unlink python
Unlinking /usr/local/Cellar/python/3.6.5... 25 symlinks removed
sudo pip3 install pygame==2.0.0.dev4

macOS Mojava10.14.6+python3.8.1+pygame==2.0.0.dev6 is ok.

Works without a problem, on a fresh Mojave install, with Python 3.7.0 from Miniconda, the version of PyGame reported is 1.9.4 .

screen shot 2018-10-21 at 7 06 20 am

Hi there,

I'm trying to get the pygame window to open but I haven't had any luck. I'm running pygame 1.9.6 with python 3.8 and macOS Mojave.
and I guess we're both working on the alien pygame project.

macOS Mojava10.14.6+python3.8.1+pygame==2.0.0.dev6 is ok.

Dude you're my hero😂

this worked for me
sudo pip3 install pygame==2.0.0.dev4

This worked for me:
brew unlink python
sudo pip3 install pygame==2.0.0.dev4

Catalina 10.15.3

Why unlink brew’s python? Please don’t use Apple’s

Just installing 2.0.0.dev4 version of pygame and using (0, 0) for the window size did the trick for me.
No messing with the system-wide python version needed.

Installing pygame 2.0.0.dev6 fixed it for me.
pip3 install pygame==2.0.0.dev6
MacOS Catalina 10.15.2.

I've created a local Portfile MacPorts-py-game2.zip for MacPorts for pygame 2.0.0.dev6, with the fix to the audio mixer problem for the aliens example. pygame 2.0.0.dev4 did not work due to "sorry, extended image module required" error. This would be easiest for those on macOS Mojave who are using MacPorts version of python.

You would need to know how to setup MacPorts to build local ports, etc.

This has been tested for Python 3.7, I didn't try to build it for the other python versions.

@mehularora8

Installing pygame 2.0.0.dev6 fixed it for me.
pip3 install pygame==2.0.0.dev6
MacOS Catalina 10.15.2.

Confirming that procedure also works for me on MacOS Catalina 10.15.4

@mehularora8

Installing pygame 2.0.0.dev6 fixed it for me.
pip3 install pygame==2.0.0.dev6
MacOS Catalina 10.15.2.

Confirming that procedure also works for me on MacOS Catalina 10.15.4

Thanks! After a few hors of googling I made it work on Catalina 10.15.4 with the latest pygame 2.0.0.dev6

the miniconda suggestion didn't work for me; what i had to do was to download the pkg file from:

https://www.python.org/downloads/release/python-370/
for python 3.7.0
and install

verify:
python3 --version
should be 3.7.0

then:
pip3 install pygame (installed 1.9.4)

then all worked.

Thanks this work for me as well

Python 3.8.5 (from Homebrew)
macOS Catalina 10.15.6
pip3 install pygame==2.0.0.dev10

Works like a charm 😅

I had issues with pygame 1.9.6 - empty gray screen. Also, cmd+q and cmd+w didn't work at all. Now they do 🥂🍾

Python 3.8.5 (from Homebrew)
macOS Catalina 10.15.6
pip3 install pygame==2.0.0.dev10

Works like a charm 😅

I had issues with pygame 1.9.6 - empty gray screen. Also, cmd+q and cmd+w didn't work at all. Now they do 🥂🍾

same versions, but not working :(