snaiperis
Posts: 8
Joined: Sat Feb 14, 2015 12:26 am

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

Sun Apr 23, 2017 12:51 am

Hello,


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

Code: Select all

sudo apt-get install python-pip
sudo pip install pygame
without success. I've got error: sdl-config not found.


Best regards
Last edited by snaiperis on Sun Apr 23, 2017 8:51 pm, edited 1 time in total.

User avatar
Jednorozec
Posts: 809
Joined: Sun Nov 24, 2013 2:17 pm
Location: Deposit, NY

Re: How to install pygame?

Sun Apr 23, 2017 1:18 am

Sometimes it's a good idea to RTFM https://www.pygame.org/wiki/GettingStarted
The most important leg of a three legged stool is the one that's missing.
It's called thinking. Why don't you try it sometime?

snaiperis
Posts: 8
Joined: Sat Feb 14, 2015 12:26 am

Re: How to install pygame?

Sun Apr 23, 2017 1:35 am

Hi,

I've read ir before posting. TFM says:
Raspberry PI
This comes with pygame already installed on the default raspberian installation.
It sounds like already installed, but:

Code: Select all

root@raspberrypi:~# uname -a
Linux raspberrypi 4.4.50+ #970 Mon Feb 20 19:12:50 GMT 2017 armv6l GNU/Linux
root@raspberrypi:~# python
Python 2.7.9 (default, Sep 17 2016, 20:26:04)
[GCC 4.9.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pygame
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named pygame
>>>
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:

Code: Select all

root@raspberrypi:/# python3 -m pip install pygame --user
/usr/bin/python3: No module named pip

Best regards

User avatar
Jednorozec
Posts: 809
Joined: Sun Nov 24, 2013 2:17 pm
Location: Deposit, NY

Re: How to install pygame?

Sun Apr 23, 2017 2:09 am

I just took a look at the latest Raspbian and pip, pip3 and pygame are all there. You might try reinstalling Raspbian.
The most important leg of a three legged stool is the one that's missing.
It's called thinking. Why don't you try it sometime?

User avatar
DougieLawson
Posts: 39121
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: How to install pygame?

Sun Apr 23, 2017 7:45 am

Jednorozec wrote:I just took a look at the latest Raspbian and pip, pip3 and pygame are all there. You might try reinstalling Raspbian.
Those things may not be there on Raspbian Jessie Lite. Try re-installing the Full Raspbian Jessie (not the light version).
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

hommar
Posts: 191
Joined: Sat Mar 25, 2017 1:55 pm
Location: Russia, Yekaterinburg

Re: How to install pygame?

Sun Apr 23, 2017 8:47 am

try this script sudo ./python_games_install.sh

Code: Select all

#!/bin/bash -e

wget "https://github.com/KenT2/python-games/tarball/master" -O python_games.tar.gz

ln -sf pip3 /usr/bin/pip-3.2

install -v -o pi -g pi -d /home/pi/python_games
tar xvf python_games.tar.gz -C /home/pi/python_games --strip-components=1
chown pi:pi /home/pi/python_games -Rv
chmod +x /home/pi/python_games/launcher.sh

install -v -o pi -g pi -d "/home/pi/Documents"
install -v -o pi -g pi -d "/home/pi/Documents/BlueJ Projects"
install -v -o pi -g pi -d "/home/pi/Documents/Greenfoot Projects"
install -v -o pi -g pi -d "/home/pi/Documents/Scratch Projects"
mkdir -p /usr/share/doc/BlueJ/
mkdir -p /usr/share/doc/Greenfoot/
mkdir -p /usr/share/scratch/Projects/Demos/
rsync -a --chown=pi:pi /usr/share/doc/BlueJ/ "/home/pi/Documents/BlueJ Projects"
rsync -a --chown=pi:pi /usr/share/doc/Greenfoot/ "/home/pi/Documents/Greenfoot Projects"
rsync -a --chown=pi:pi /usr/share/scratch/Projects/Demos/ "/home/pi/Documents/Scratch Projects"

#Alacarte fixes
install -v -o pi -g pi -d "/home/pi/.local"
install -v -o pi -g pi -d "/home/pi/.local/share"
install -v -o pi -g pi -d "/home/pi/.local/share/applications"
install -v -o pi -g pi -d "/home/pi/.local/share/desktop-directories"

snaiperis
Posts: 8
Joined: Sat Feb 14, 2015 12:26 am

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

Sun Apr 23, 2017 8:13 pm

Hi,

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!!!

The final solution is trivial:

Code: Select all

sudo apt-get install python3-pygame

Best regards

MrMeowington
Posts: 3
Joined: Mon Aug 13, 2018 2:02 am

Re: How to install pygame?

Mon Aug 13, 2018 2:24 am

hommar wrote:
Sun Apr 23, 2017 8:47 am
try this script sudo ./python_games_install.sh

Code: Select all

[CODE SNIPPED]
Hey there! Thanks for the script!
I was able to use this script with some modification first.
In the future, try using

Code: Select all

~/
instead of

Code: Select all

/home/pi
as ~ references the home folder of the current user, but /home/pi requires the user to change it to fit their own username. I, personally, have changed my username, so I had to change this.
You should also make it more clear what the user needs to change themselves. Try this code instead:

Code: Select all

#!/bin/bash -e

wget "https://github.com/KenT2/python-games/tarball/master" -O python_games.tar$

ln -sf pip3 /usr/bin/pip-3.2

install -v -o USERNAME -g pi -d ~/python_games
tar xvf python_games.tar.gz -C ~/python_games --strip-components=1
chown USERNAME:pi ~/python_games -Rv
chmod +x ~/python_games/launcher.sh

install -v -o USERNAME -g pi -d "~/Documents"
install -v -o USERNAME -g pi -d "~/Documents/BlueJ Projects"
install -v -o USERNAME -g pi -d "~/Documents/Greenfoot Projects"
install -v -o USERNAME -g pi -d "~/Documents/Scratch Projects"
mkdir -p /usr/share/doc/BlueJ/
mkdir -p /usr/share/doc/Greenfoot/
mkdir -p /usr/share/scratch/Projects/Demos/
rsync -a --chown=USERNAME:pi /usr/share/doc/BlueJ/ "~/Documents/BlueJ Projects"
rsync -a --chown=USERNAME:pi /usr/share/doc/Greenfoot/ "~/Documents/Greenfoot Projects"
rsync -a --chown=USERNAME:pi /usr/share/scratch/Projects/Demos/ "~/Documents/Scratch Projects"

#Alacarte fixes
install -v -o USERNAME -g pi -d "~/.local"
install -v -o USERNAME -g pi -d "~/.local/share"
install -v -o USERNAME -g pi -d "~/.local/share/applications"
install -v -o USERNAME -g pi -d "~/.local/share/desktop-directories"

Other than that, the code is perfect!

For coding newbies, here's how to use .sh code in forum posts:
  1. Copy the entire code
  2. Open the Terminal and type:

    Code: Select all

    nano FILENAME-WITHOUT-SPACES.sh
    This will open a new file with that name.
  3. Press Ctrl+Shift+V to paste the code into the file.
  4. Make any necessary changes to the code.
  5. Press Ctrl+X, then press Y, then Enter to save the code.
  6. Run this script to give yourself permission to run the script:

    Code: Select all

    chmod +x ./FILENAME-WITHOUT-SPACES.sh
  7. Type the following command to run the code in the file:

    Code: Select all

    ./FILENAME-WITHOUT-SPACES.sh
    If the script requires root permissions, type sudo before it:

    Code: Select all

    sudo ./FILENAME-WITHOUT-SPACES.sh
Hope this helps!
To code, or not to code...
That is the question.

Return to “General discussion”