I'm using pygame to write some games on my macbook pro 2018, and using the python in anaconda, the FPS is very low, after some research I found this solution Pygame application runs slower on Mac than on PC, it's says set the python to "Open in Low Resolution", I did the first 5 steps, but the python3.6 in anaconde dose not end with .app, so it doesn't have the "Open in Low Resolution" checkbox, can anyone tell me how to deal with this? many thanks!
OK, I solved it,
TLDR
pip uninstall pygame
pip install pygame==2.0.0.dev6
seemd the SDL used by pygame can't work correctily on MacBook, and pygame2 use SDL2 that doesn't have that issue
Related
I recently got a new computer (Mac 14" Monterey OS) and reinstalled Python, PyCharm, etc. Everything seems to work okay except when running turtle Screen(). The code finishes with exit code 0 (no errors) but when the launcher pops up its just a tiny black screen that flickers. Doesn't even display the title correctly anymore.
It seems I've tried everything: re-installing Python, installing a later version (Python 3.9 vs 3.10) and reinstalling PyCharm, making sure the interpreter is okay. Nothing is working. I've spent about 2 hours googling to find a solution. I'm stuck and frustrated since I am supposed to be doing a coding workthrough with a company this coming week.
Here is the code that should be running:
import turtle
screen = turtle.Screen()
screen.title("States Game")
image = "blank_states_img.gif"
screen.addshape(image)
turtle.shape(image)
def get_mouse_click_coor(x, y):
print(x, y)
turtle.onscreenclick(get_mouse_click_coor)
screen.exitonclick()
And here is an image of what is going on...
please click this link to see image
Check your python interpreter version.
I have the same issue when it uses python3.8, after upgrading to 3.9. It works perfectly.
You need to install Python yourself instead of relying on the Python provided by macOS. I downloaded latest macOS 64-bit universal2 installer from https://www.python.org/downloads/macos/ and it works. (make sure you create new interpreter in Pycharm, using the newly installed python)
I think the cause of the issue is that the tkinter package has issues for the builtin python.
I think my code is nothing wrong. Because it's very simple, it worked very well on my Windows PC, and shows no error message at all.
from turtle import Turtle, Screen
turtle = Turtle()
screen = Screen()
screen.exitonclick()
However, on Pycharm on my Monterey M1 Macbook, the Python Turtle Graphics window shows nothing but black screen and scroll bars.
I think the application called python.app is something wrong. That's why I updated python with brew and re-installed Pycharm, but nothing has changed.
Does anyone know how to fix this?
Thank you.
have you tried to install the latest version of python? cause I'm facing the same problem earlier. I tried to install the latest python version and it just works like a charm now.
change the interpretepycharm interpreterr to 3.9 or 3.10 in pycharm.
Updating the interpreter will help fix the issue as it did in my M1 Mac and without needing to make a new project. However, there are a few extra steps needed to make sure it's compatible with your M1 chip.
Quick Steps:
Download the latest Python version (Make sure the download link is labeled as "macOS 64-bit universal2 installer" as it'll be fully compatible with your M1 Mac)
After installing the interpreter, open Pycharm -> Preferences -> Project: [Your Poject's Name] -> Python Interpreter
Click the Options button (Gear Button) next to the Python Interpreter Box and select "Add..."
Make sure "New Environment" is selected
Select any empty folder (or make one) to store your interpreter (I chose to store it in Documents in the "Personal Python Interp" folder)
For "Base Interpreter: ", "select the button with the three dots and paste /Applications/Python 3.10/IDLE.app/Contents/MacOS/Python, then press "OK" (IMPORTANT: Your Python version number may be different so update the "Python 3.10" to the python folder name found in "Applications")
Check both boxes for "Inherit global site-packages" and "Make available to all projects" (UNLESS you have specific interpreters for other projects)
If any, re-download any Python Packages you may need onto this interpreter
The turtle screen should be now fixed! I hope this helped!
I don't think it has anything to do with the M1 processor.
I have an M1 processor and had the same problem.
My solution:
Create a new project in Python.
Previously configured interpreter
Select Python 3.10 (the latest installed version).
Click the button with the three dots ...
Go to the directory of Python 3.10 (current version).
IDLE.app -> Contents -> MacOS and -> Select Python.
For me it looks like this:
/Applications/Python 3.10/IDLE.app/Contents/MacOS/Python
Then it works for me.
Running:
macOS Catalina 10.15.1
Python 3.8.0
Pygame 1.9.6
IDE - Visual Studio Code 1.40.2
When I launch the Pygame test:
python3 -m pygame.examples.aliens
The music begins playing and after about 5 seconds the app closes. No window appears. The icon in dock shows up until it's closed.
The same thing happens with a basic test code such as
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()
There are no error messages in the terminal.
Anybody have this issue? I've tried reinstalling both Python 3.8.0 from the website (as recommended in a different thread) as well as Pygame.
This solution was given by furas in this comment:
Maybe install Python 3.7. Python 3.8 is very new version and many modules are not ready or not tested for this version.
This works on Python 3.7.8.
After several trials I have found out that the problem can be solved with one of two ways, You may try each solution one by one as one have worked with some friends and other have worked with others.
My system info:
macOS Catalina 10.15.6
Python 3.8.5
All solutions depends on trying latest Pygame developer versions (knowing many would say its not final release and it might be not stable but i believe this is much better than downgrading your macOS version).
Solution A:
At Terminal, try installing Pygame dev 4
pip3 install pygame==2.0.0.dev4
This solution allow me to work with most codes but when I try some samples online
it give me this error "Sorry, extended image module required"
Solution B:
At Terminal, try installing Pygame dev 4
pip3 install pygame==2.0.0.dev6
This time it works perfectly form we for all online and offline codes
To Test result try this sample
python3 -m pygame.examples.aliens
Here is a screenshot for the previous sample after fixing the issue:
I couldn't resize my windows on the applications i made with Kivy, so I found out using sdl2, instead of Pygame, with Kivy can fix this. I uninstalled Kivy and Pygame, then installed sdl2, then reinstalled Kivy. Kivy still is trying to use pygame though. Please Help.
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/kivy/core/__init__.py", line 59, in core_select_lib
fromlist=[modulename], level=0)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/kivy/core/window/window_pygame.py", line 8, in <module>
import pygame
The easiest way to fix this is to purge your current kivy install and re-install it fresh using the following links as a reference point (these are the official installation instructions)
https://kivy.org/docs/installation/installation-windows.html
With that being said please note the following, do to an issue with a few compilers 1.9.2 doesn't work on windows with python 3.5 this is an ongoing issue the kivy team is aware of and working on.
So this means you're left with using python 3.4 for the newest version(s) of kivy on windows. Kivy no longers uses pygame and should by default prompt you to install sdl2.
The only issue you may have with the official instructions in the link I provided is setting up GStreamer if it gives you a problem you can skip that and just grab a ported version which suffices.
If you're on Linux then just re-install :)
I had the same issue on my new Mac (Sierra). I followed the suggestion at https://github.com/kivy/kivy/issues/4688
and installed the latest version of Kivy using the command
USE_OSX_FRAMEWORKS=0 pip install https://github.com/kivy/kivy/zipball/master
This worked for me, and Kivy is now using SDL2 and not looking for pygame.
(I also answered this at: Kivy support for SDL2 in Virtualenv)
I couldn't resize my windows on the applications i made with Kivy, so I found out using sdl2, instead of Pygame, with Kivy can fix this. I uninstalled Kivy and Pygame, then installed sdl2, then reinstalled Kivy. Kivy still is trying to use pygame though. Please Help.
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/kivy/core/__init__.py", line 59, in core_select_lib
fromlist=[modulename], level=0)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/kivy/core/window/window_pygame.py", line 8, in <module>
import pygame
The easiest way to fix this is to purge your current kivy install and re-install it fresh using the following links as a reference point (these are the official installation instructions)
https://kivy.org/docs/installation/installation-windows.html
With that being said please note the following, do to an issue with a few compilers 1.9.2 doesn't work on windows with python 3.5 this is an ongoing issue the kivy team is aware of and working on.
So this means you're left with using python 3.4 for the newest version(s) of kivy on windows. Kivy no longers uses pygame and should by default prompt you to install sdl2.
The only issue you may have with the official instructions in the link I provided is setting up GStreamer if it gives you a problem you can skip that and just grab a ported version which suffices.
If you're on Linux then just re-install :)
I had the same issue on my new Mac (Sierra). I followed the suggestion at https://github.com/kivy/kivy/issues/4688
and installed the latest version of Kivy using the command
USE_OSX_FRAMEWORKS=0 pip install https://github.com/kivy/kivy/zipball/master
This worked for me, and Kivy is now using SDL2 and not looking for pygame.
(I also answered this at: Kivy support for SDL2 in Virtualenv)