Install pygame raspberry

Install pygame raspberry

how to install pygame on the newest 2017-04-10 Raspbian release. I’ve tried

without success. I’ve got error: sdl-config not found.

Re: How to install pygame?

Re: How to install pygame?

I’ve read ir before posting. TFM says:

and I also did not find any pygame* files using recursive search from / , so, I doubt it is already installed by default.

Then I have tried to follow instructions:

Re: How to install pygame?

Re: How to install pygame?

Languages using left-hand whitespace for syntax are ridiculous

DMs sent on https://twitter.com/DougieLawson or LinkedIn will be answered next month.
Fake doctors — are all on my foes list.

The use of crystal balls and mind reading is prohibited.

Re: How to install pygame?

[SOLVED] How to install pygame on Raspbian jessie lite?

To Jednorozec: I’ve used the latest Raspbian of 2017-04-10, and I’ve tried a few times reinstallation and various package installation.

To DougieLawson: Yes! I used jessie lite. This is headless application, and I need pygame to play a multiple sounds simultaneously. So, I want to avoid a full GUI installation on headless computer.

I was unable to find pygame working, because I’ve used «python» for importing module test. I should use «python3»! Thank for ideas anyway.

Источник

Can’t install pygame on mac

I’m trying to install pygame on my mac, when I import pygame , below error returned

I have seen it is a architecture problem, however I’m not aware of how to install 32bit python.

Thanks in advance

3 Answers 3

For me actually, in 03/2020 with the latest OS / Python etc. I used all commands except for the last one which did not work. I simply run this and SUCCESS(!):

EDIT: I realized that these steps were originally intended for python3. It should still work for python2, but I can’t confirm, it’s just the best answer I have.

Assuming you are using the newest macOS, here are the steps I used to install pygame. Try and uninstall what you installed for pygame previously, I’m not sure how this could affect it. This will also install the IDLE program, a python IDE developed by python, if you don’t already have it.

If you have an older mac, click the source link at the bottom, which we provide instructions for older macs, which would involve downloading programs like xcode.

Install homebrew. Go into terminal and paste

ruby -e «$(curl -fsSL https ://raw.githubusercontent.com/Homebrew/install/master/install)»

Paste the following into terminal, hitting enter after each line:

brew install python ( brew install python3 for python3 users)

brew install mercurial

brew install sdl sdl_image sdl_mixer sdl_ttf portmidi

brew tap homebrew/headonly (if you have any trouble here, try brew install —HEAD smpeg instead)

Источник

Python Programming Tutorial: Getting Started with the Raspberry Pi

Experiment 2: Play Sounds

Downloading audio clips and playing them on a Raspberry Pi is quite simple. We will use the command line to download a .wav file, adjust the audio, and test playing the file. Then, we’ll write a Python script to play that file whenever we press a button!

  • amixer — We will be using the amixer Linux tool to adjust the volume on our Raspberry Pi
  • Pygame — Pygame is a framework that is used for making simple games in Python. Raspbian comes pre-loaded with Pygame, which means we can use it to play sounds.

Hardware Connections

Good news, everyone! We will be using the same circuit from the previous experiment.

  • Connect GPIO12 (pin 32) to the 330Ω resistor, and the resistor to the LED
  • Connect GPIO4 (pin 7) to the button
  • Make the power (3.3 V) and ground (GND) connections as shown in the Fritzing diagram

Connecting through a Pi Wedge:

Connecting directly to the Raspberry Pi:

You will also need to plug an external speaker (or a set of headphones) into the Pi’s headphone jack. If you are using the Hamburger Mini Speaker, make sure it is charged and turned on.

Configure Audio

Before we write code, we need to configure the audio from the command line. Open a terminal (if you are using Raspbian with a desktop).

From a terminal, enter the following commands:

Verify that your audio is on and up by entering the command:

At the end of the printout, you should see Mono: Playback 400 [100%] [4.00dB] [on] .

Download a free sound clip (we’ll go with some applause, because we’re awesome):

Test playing this sound with:

You should hear some nice cheering and clapping out of your speaker (or headphones).

Code: Push Button, Get Sound

Depending on your version of Raspbian, you may or may not have to install the pygame package (e.g. Raspbian Lite does not come with some Python packages pre-installed). In a terminal, enter the following:

In a new file, enter the following code:

Save the file (e.g. applause.py), and start the program with python applause.py . Push the button, and you should hear some congratulatory sounds!

Code to Note:

To play sounds, we are using the pygame package. A package in Python is a collection of modules grouped together. Lucky for us, pygame comes pre-installed with Python on Raspbian. To use it, we just need to use from pygame in our code, and we can specify which module we want to use by saying import after it. For example, we might say:

This says that we want to import the mixer module from the pygame package. Later in our code, we can use the mixer module to create a Sound object with:

Our downloaded file, applause-1.wav is used to create a Sound object, which we store in the sound variable. We can call the .play() method in our Sound object to start playing the .wav file.

Источник

Install pygame raspberry

I have installed pygame successfully using sudo apt-get install python-pygame

However when I use import pygame
from pygame.locals import *

I get the error;
ImportError: No module named pygame

I realise this is basic stuff but I’m a total Linux novice and been reading the User Guide for ages but can’t seem to figure this one out!

Re: pygame installation problem

Re: pygame installation problem

Re: pygame installation problem

Re: pygame installation problem

Copy it from your editor (Idle, Geany, etc.) then above the edit box when you reply to this click the ‘Code’ button and paste your code between the tags.
It’ll make it much easier to help.

Re: pygame installation problem

Re: pygame installation problem

I will try later when I get the Pi out again.

Re: pygame installation problem

Thanks very much — it worked!

Initially mercurial didn’t install correctly so hg wasn’t found. I did an update then it worked well.

Re: pygame installation problem

Re: pygame installation problem

Re: pygame installation problem

Just to say thanks for this again.

If anyone is thinking of doing this, the whole process takes the best part of an hour.

Re: pygame installation problem

Re: pygame installation problem

esr/faqs/smart-questions.html
How to Report Bugs Effectively: http://www.chiark.greenend.org.uk/

Re: pygame installation problem

Re: pygame installation problem

I gave a specific answer to a specific question. But I’m not sure it helps you with your MagPi query?

Well if you’ve got pygame installed you don’t need to be concerned with the instructions you supplied as a quote, because they are about getting pygame installed, not about using it in a python script.

So, what is the error you get? Is it something like:

If so, then you don’t have pygame installed for python3. (Note that for practical purposes python (ie. Python 2.7.3) and python3 are separately installed and supported languages, and have their own supporting libraries and modules. If you are checking around on your system for any instance of pygame it is probably the python2 version which is installed in Raspbian by default that you are finding.

In case you haven’t tried — although the MagPi article says ‘tested with Python 3.2.2’, it actually runs without complaint under Python 2.7.3 — but I use my RPi ‘headless’ (without Graphics) so I can’t say that it runs faultlessly.

esr/faqs/smart-questions.html
How to Report Bugs Effectively: http://www.chiark.greenend.org.uk/

Re: pygame installation problem

I’m getting an error when I use the last two commands as follows:

python3 setup.py build

WARNING, No «Setup» File Exists, Running «config.py»
Using UNIX configuration.

Hunting dependencies.
/bin/sh: 1: sdl-config: not found
/bin/sh: 1: sdl-config: not found
/bin/sh: 1: sdl-config: not found
WARNING: «sdl-config» failed!
/bin/sh: 1: smpeg-config: not found
/bin/sh: 1: smpeg-config: not found
/bin/sh: 1: smpeg-config: not found
WARNING: «smpeg-config» failed!
Unable to run «sdl-config». Please make sure a development version of SDL is installed.

Re: pygame installation problem

I have tried the method suggested by croston above, but with no success, everywhere I go I see that method appearing and reappearing over and over again, does anyone else have another method to install it by. Your help is greatly appreciated.

When I type:
pi@raspberrypi

destination directory: pygame
abort: destination ‘pygame’ is not empty

Re: pygame installation problem

maximoose wrote: I have tried the method suggested by croston above, but with no success, everywhere I go I see that method appearing and reappearing over and over again, does anyone else have another method to install it by. Your help is greatly appreciated.

When I type:
pi@raspberrypi

destination directory: pygame
abort: destination ‘pygame’ is not empty

That means that you already have that directory (folder) there. Probable explanation: You have already done that step before. You could delete the folder and then try again from the start or assume that you have already done the cloning step (correctly )and continue with the next command in the instructions. Maybe the first option is safer in case there is been some problem with the cloning when you did that before.

Источник

How to install pygame 2.0.0 from source or directly in raspberry pi #2018

Comments

martinlombana commented Jul 19, 2020 •

[First see this page for apt-get instructions on pi: https://www.piwheels.org/project/pygame/ Edit: use python3 -m pip install pygame for latest pygame 2 version that runs good]

Hi have successfully installed pygame 1.9.2, but I wanted to try the new things in version 2.
What is the direct way to install it on raspbian lite (raspberry pi3).

I previously installed with ‘sudo apt-get install python3-pygame’ but it seems there is no version 2 published. Is there an alternative way to install version2 on a raspberry pi?

The text was updated successfully, but these errors were encountered:

ghost commented Jul 21, 2020 •

Pygame 2 dev releases are available from pypi/piwheels. You can can install them with pip:
python3 -m pip install pygame —pre
This will use the pip from your python3 to install the latest dev (—pre) version of pygame.
You should do it in a virtual environment if you want to keep the old version at the same time.
https://packaging.python.org/tutorials/installing-packages/#creating-virtual-environments

Building from source on Raspbian is really easy. Simply download it and run setup.py. The script will print the dependencies you need to compile. You can then install them with apt-get and run setup.py again.

Also, pygame 1.9.2 is almost 4 years old and I’m sure the version provided with Raspbian/RaspberryPiOS is at least a bit more up to date. I guess you are also using an old version of Raspbian.

© 2022 GitHub, Inc.

You can’t perform that action at this time.

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.

Источник