Установка pygame mac os

Содержание
  1. GettingStarted — wiki
  2. Pygame Installation¶
  3. Next steps. ¶
  4. Further info on installation¶
  5. Raspberry Pi¶
  6. Windows installation¶
  7. Mac installation¶
  8. Recent versions of Mac OS X require pygame 2¶
  9. virtualenv issue¶
  10. Anaconda Mac¶
  11. Unix Binary Packages¶
  12. Debian/Ubuntu/Mint¶
  13. Fedora/Red hat¶
  14. OpenSUSE¶
  15. Installing From Source¶
  16. Compilation¶
  17. Mac OS X Compiling Info¶
  18. Installing Pygame on Mac OS 10.8 Mountain Lion
  19. What didn’t work
  20. What actually got Pygame working
  21. Additional details
  22. Hi! I’m James.
  23. Install Pygame in MacOS
  24. Installing dependency
  25. Installing PyGame
  26. Install Pygame in Mac OS X
  27. Discussion (0)
  28. Read next
  29. Installing Python3, Pip and AWS CLI on macOS Sierra
  30. Answer: Combining conda environment.yml with pip requirements.txt
  31. SoapUi Load Test reporting Dashboard
  32. Most Popular Backend Frameworks of 2021
  33. More from darkside haguremetal
  34. connorshea / pygameinstall.md
  35. This comment has been minimized.
  36. BrendonYim commented Jun 28, 2016
  37. This comment has been minimized.
  38. rafajaques commented Apr 19, 2017
  39. This comment has been minimized.
  40. cbscribe commented May 1, 2017
  41. This comment has been minimized.
  42. SeanFelipe commented Sep 12, 2017
  43. This comment has been minimized.
  44. tenzin113 commented Dec 26, 2017
  45. This comment has been minimized.
  46. dhayden commented Jan 23, 2018
  47. This comment has been minimized.
  48. TedTheGreatProgrammer commented Feb 24, 2018
  49. This comment has been minimized.
  50. bobbytoo2 commented Mar 14, 2018
  51. This comment has been minimized.
  52. oestrogen commented Mar 15, 2018 •
  53. This comment has been minimized.
  54. IamSandeepKrishnan commented Apr 15, 2018
  55. This comment has been minimized.
  56. MisterFili commented Jul 14, 2018

GettingStarted — wiki

Pygame Installation¶

Pygame requires Python; if you don’t already have it, you can download it from python.org. Use python 3.7.7 or greater, because it is much friendlier to newbies, and additionally runs faster.

The best way to install pygame is with the pip tool (which is what python uses to install packages). Note, this comes with python in recent versions. We use the —user flag to tell it to install into the home directory, rather than globally.

To see if it works, run one of the included examples:

Next steps. ¶

  • Having a go at one of the tutorials.
  • Or dive right into the pygame Docs

Further info on installation¶

Hopefully the installation instructions above worked for you. If not, please read some alternative installation methods, and extra details below.

Wheels are available for x86 and x64 architectures on Linux and Windows, and for x64 on Mac. If pip doesn’t find a wheel for your platform, it will try to compile pygame from source (see below).

pygame requires a «newer» pip. If pygame starts compiling from source and fails, first try upgrading pip.

Raspberry Pi¶

This comes with pygame already installed on the default raspbian installation.

Windows installation¶

Make sure you install python3.6 with the «Add python 3.6 to PATH» option selected. This means that python, and pip will work for you from the command line.

There is documentation with python for the «windows installation steps»

Notice that this does not seem to work with Python 3.9 — use 3.7.

Mac installation¶

Recent versions of Mac OS X require pygame 2¶

If your examples aren’t running and you are using a recent version of Mac OS X; try this line to install pygame instead:

virtualenv issue¶

There are problems with ‘

‘ and pygame on mac, where it loses focus. More details here: details on the virtualenv issue. It does work if you create a venv with python -m venv however. Instructions if you want to use an virtualenv (some people have trouble with the window losing focus when inside a venv).

Anaconda Mac¶

(note the w on the end). If it doesn’t work for you, please see the /wiki/MacCompile instructions.

Unix Binary Packages¶

Many Linux and BSD distributions have their own packages of Pygame. These may have an older version of Pygame than the wheels, but have been carefully tested with other packages in that distribution.

Читайте также:  Настройка уровня микрофона windows 10

Debian/Ubuntu/Mint¶

Fedora/Red hat¶

OpenSUSE¶

Arch/Manjaro

Distribution Python 3 package Python 2 package Debian/Ubuntu python3-pygame python-pygame Fedora python3-pygame pygame

FreeBSD also has an active pygame package. While techinicaly it isn’t binary, it is automatically built and installed by the ports manager. See the FreeBSD package page for more information. http://www.freebsdports.info/ports/devel/py-game.html

Gentoo has a builtin package for pygame. This is compiled for your system as it installs, similar to BSD, http://packages.gentoo.org/package/dev-python/pygame

Installing From Source¶

Compilation¶

Compiling and installing pygame is handled by Python’s distutils. Pygame also comes with some scripts to automatically configure the flags needed to build pygame. Use the «setup.py» script to start the installation.

The first time you run the setup script, it will call the «config.py» script. This will build a «Setup» file which stores all the information needed to compile. The «config.py» will do a good job of detecting what dependencies are available and where they are located. If it isn’t perfect, it is easy to build your own, or edit the created «Setup» text file. This «Setup» file is a simple Makefile-like text file. It defines variables needed to use each dependency, and then enables all the pygame modules with found dependencies. If you have trouble compiling, you should be able to easily fix any problems inside the «Setup» file.

Running the «setup.py» script will call distutils to build and install the pygame package. Distutils actually supports a wide variety of compile and install options. running «python setup.py help» will start to show you the different options available. You can change many things like install locations, compiler to use, and more. Calling the «setup.py» script with no arguments and it will just ask you if you want the default flags needed to compile and install.

Some of the .c files are generated by Cython from .pyx files. Running «setup.py cython» will update them.

Windows Compiling Info

You can compile pygame on windows with mingw (gcc for windows) and also with visual studio. Up to date details can be found here: CompileWindows

Unix Compiling Info

Compiling from linux shouldn’t give you any problems. One thing you must keep in mind is that most linux RPM packages separate the actual library from the «dev» files needed to compile. To build you will need to make sure the packages like «SDL-dev» are installed.

You can check to see if SDL is ready to be built from by running the command sdl-config and seeing if it is found. If the sdl-config script is not on the path (or you have more than one?) Set the environment variable SDL_CONFIG to its location.

Sometimes you will have the SDL libraries installed in once location, and the other SDL libraries in another. This tricks the pygame config scripts, but you can help it out by setting the environment LOCALBASE to a path prefix where the other libraries are. The common case for this is SDL installed in /usr and other SDL libs installed in /usr/local. The command for this situation is «LOCALBASE=/usr/local python setup.py install«.

Mac OS X Compiling Info¶

Up to date instructions for compiling on Mac OS X can be found here: MacCompile

Источник

Installing Pygame on Mac OS 10.8 Mountain Lion

I decided to install and play around with Pygame today, mainly as an excuse to write some Python for a minor departure from all the Javascript/Coffeescript I’ve been writing lately. Unfortunately the process wasn’t entirely frictionless, due to Pygame not yet accounting for Apple’s move to XQuartz as the recommended X11 implementation for Mac OS as of 10.8 Mountain Lion. As a result I ran into some compilation errors while Pygame was building it’s native extensions, which fortunately were not too hard to fix as I had some familiarity with changes to X11 on Mountain Lion.

Читайте также:  Psi plus для windows

What didn’t work

Running pip install pygame would fail as follows:

While building the native extention ‘pygame.display’, Xlib.h (a particular X11 header, required by SDL) is not found, as XQuartz’s /opt/X11/include directory has not been specified to search for headers.

By setting some environment variables, we can configure the Pygame build process to build correctly. I found these in a few other blog posts, but they specified only -arch i386 for CFLAGS, LDFLAGS and ARCHFLAGS, which allowed the build process to complete, but import pygame fails (when running 64bit Python):

What actually got Pygame working

The environment variables (gcc flags) required to allow Pygame to correctly build fat binaries (for both 32bit and 64bit Python) are:

Then pip install pygame and python -c ‘import pygame’ . If no error is returned by Python, then you should now have a working installation of Pygame.

Additional details

I’m using homebrew-installed Python/pip, and I’ve set my $PATH with /usr/local/bin before the system-installed Python.

If you haven’t installed Python/pip via homebrew (you’re using the system-installed Python), you would likely need to run sudo pip install pygame .

If you’re using another install method, such as easy_install, this fix should still work.

Before running pip install pygame , I had also installed Command Line Tools for XCode (walkthrough), as well as XQuartz, and the following homebrew packages: brew install sdl sdl_image sdl_mixer sdl_ttf smpeg portmidi .

If homebrew fails to install smpeg you might need to do the following:

Hi! I’m James.

I make neat stuff on the web.
I’m into UX, music production, designing the future, and learning from the past.

Источник

Install Pygame in MacOS

PyGame is a collection of modules that break through the language of Python applications. These modules are designed to edit video games. PyGame, therefore, includes computer graphics and audio libraries created for the use and language of Python programs.

At first, open the Terminal which is located at Applications -> Utilities -> Terminal and make sure that the Python3 is installed in your system. If it is not installed then type the below command.

Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.

To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning — Basic Level Course

Installing dependency

XCode: The first step for PyGame is to install Apple’s Xcode program. In your Terminal app, enter and run the following command to install XCode.

Be sure to click on all the verification recommendations that require XCode

Installing PyGame

We can now install the latest version of PyGame. Type the following command in Terminal and press Enter.

To test if PyGame has been installed on your Mac, open terminal and type python, and import pygame as follows

If you don’t see any errors, it means that PyGame has been successfully installed on your Mac.

Источник

Install Pygame in Mac OS X

  • Mac OS X 10.14 Mojave
  • Anaconda3-5.3.1
  • Python 3.7.2

Discussion (0)

Installing Python3, Pip and AWS CLI on macOS Sierra

Stevo Perisic — Oct 3 ’18

Answer: Combining conda environment.yml with pip requirements.txt

Nilotpal Choudhury — Jun 7 ’20

SoapUi Load Test reporting Dashboard

Akshay C A — Oct 10

Читайте также:  Error message when starting windows

Atharva Kamble — Oct 10

More from darkside haguremetal

DEV Community – A constructive and inclusive social network for software developers. With you every step of your journey.

Built on Forem — the open source software that powers DEV and other inclusive communities.

Made with love and Ruby on Rails. DEV Community © 2016 — 2021.

We’re a place where coders share, stay up-to-date and grow their careers.

Источник

connorshea / pygameinstall.md

Then you can run Python scripts from the Terminal with python filename.py .

Why use Homebrew? So when you install things you can easily remove and reinstall them if they break, remove them if they’re misbehaving or you no longer need them, or update your packages whenever updates come out (you can do that with brew update then brew upgrade ). It also makes installing all kinds of languages and things super easy.

This comment has been minimized.

Copy link Quote reply

BrendonYim commented Jun 28, 2016

I install all pygame follow all steps, but I got error like that

This comment has been minimized.

Copy link Quote reply

rafajaques commented Apr 19, 2017

AFAIK, pygame does not work well with python 3.

This comment has been minimized.

Copy link Quote reply

cbscribe commented May 1, 2017

AFAIK, pygame does not work well with python 3.

This is completely false. I have been using and teaching pygame with Python 3 for years now.

Also, these steps are all no longer necessary. This used to be the preferred method for OS X, but a few months ago Pygame distribution was updated and now all you need to do for all platforms is:

This comment has been minimized.

Copy link Quote reply

SeanFelipe commented Sep 12, 2017

Thanks for the tips!

This comment has been minimized.

Copy link Quote reply

tenzin113 commented Dec 26, 2017

This comment has been minimized.

Copy link Quote reply

dhayden commented Jan 23, 2018

worked for me. I’m running MacOS with Sierra. Thanks!

This comment has been minimized.

Copy link Quote reply

TedTheGreatProgrammer commented Feb 24, 2018

It didn’t work! Permission denied. I tried to install pygame but I failed.

Mac OS High Sierra

This comment has been minimized.

Copy link Quote reply

bobbytoo2 commented Mar 14, 2018

It worked for me: MacOS High Sierra, but it only installed for Python 2.7. How do I get it on Python 3.6.4? My Python3 is downloaded through Anaconda, if that’s useful to know.

This comment has been minimized.

Copy link Quote reply

oestrogen commented Mar 15, 2018 •

@bobbytoo2 Run the same commands, but with pip3 instead of pip , to install libraries for Python 3.

This comment has been minimized.

Copy link Quote reply

IamSandeepKrishnan commented Apr 15, 2018

Can i install pygame without installing Xcode ? I am conscious that Xcode is a 6 GB file and i don’t programme in Xcode. I just need pygame but its failing to install without xcode —>

gcc -fno-strict-aliasing -Wsign-compare -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -arch i386 -arch x86_64 -g -Ddarwin -D_THREAD_SAFE -DENABLE_NEWBUF=1 -I/usr/X11R6/include -I/usr/local/include/SDL -I/usr/local/include/SDL -I/usr/local/include -I/usr/local/include -I/Library/Frameworks/Python.framework/Versions/3.6/include/python3.6m -c src/imageext.c -o build/temp.macosx-10.6-intel-3.6/src/imageext.o
xcrun: error: active developer path (“/Users/sandeepkrishnan/Desktop/Xcode-beta.app/Contents/Developer”) does not exist
Use sudo xcode-select –switch path/to/Xcode.app to specify the Xcode that you wish to use for command line developer tools, or use xcode-select –install to install the standalone command line developer tools.
See man xcode-select for more details.
error: command ‘gcc’ failed with exit status 1

This comment has been minimized.

Copy link Quote reply

MisterFili commented Jul 14, 2018

i’m also on a journey to configure pygame

if you follow this link HERE you will see examples.

Источник

Оцените статью