[Repost with Snapshot] Install and Run Pygame on GameShell with Miniconda

Install and Run Pygame on GameShell with Miniconda

Step1: Connect to GameShell via ssh

>> ssh cpi@
cpi@'s password: [type “cpi”]
Linux clockworkpi …
cpi@clockworkpi:~$ pwd 

You can find the address to “ssh" to by navigating to “tiny cloud” in the GameShell. The default username and password are both “cpi”.

Create a folder “downloads” in “/home/cpi/“, where we will place the Miniconda install script later.

>> mkdir downloads
>> ls 
apps  downloads games  launcher  launchergo  music  skins

Step2: Download Miniconda for Linux and Move to GameShell

I already download the miniconda install script (, which is renamed on the computer and thus I just “scp” it to the GameShell. Alternatively, you can of course download the Anaconda install script directly to the GameShell after “ssh” to it.

~ >> cd ~/Downloads 
~/Downloads >> scp cpi@

Wait until the transferring/downloading process done.

Step3: Install Miniconda on GameShell

Login to GameShell and install Miniconda.

>> ssh cpi@
cpi@'s password: [type “cpi”]
Linux clockworkpi …
cpi@clockworkpi:~$ bash downloads/

Read the terms and follow the promotions to install Miniconda. Then create the environment, say “first”, install “SDL” ([2]) and “pygame".

cpi@clockworkpi:~$ conda create -n first python=2.7

Step4: Install SDL ([2])

cpi@clockworkpi:~$ cd downloads
cpi@clockworkpi:~/downloads$ wget
cpi@clockworkpi:~/downloads$ tar -xzvf SDL-1.2.14.tar.gz
cpi@clockworkpi:~/downloads$ cd SDL-1.2.14
cpi@clockworkpi:~/downloads$ ./configure --prefix=$HOME
cpi@clockworkpi:~/downloads$ make
cpi@clockworkpi:~/downloads$ make install

Step5: Install Pygame ([2])

cpi@clockworkpi:~$ source activate first
(first) cpi@clockworkpi:~$ cd downloads
(first) cpi@clockworkpi:~/downloads$ wget
(first) cpi@clockworkpi:~/downloads$ tar -xzvf pygame-1.9.1release.tar.gz
(first) cpi@clockworkpi:~/downloads$ cd pygame-1.9.1release

Comment out the line starting with “_camera” in “Setup”, and then install the “pygame” by running:

(first) cpi@clockworkpi:~/downloads$python install

Now you can import “pygame”.

(first) cpi@clockworkpi:~/downloads$python
Python 2.7.10 …
>>> import pygame

Step6: Create a Game and Start in GameShell

Connect to GameShell and navigate into the games. Create a repository “first_game” for the new game.

(first) cpi@clockworkpi:~$ cd games
(first) cpi@clockworkpi:~/games$ mkdir first_game

Create the pygame script “” in “~/games/first_game".

import os, sys, random, time, datetime, math
import pygame
from pygame.locals import *
from pygame.color import *

GS_KEY_X = 117
GS_KEY_Y = 105
GS_KEY_A = 106
GS_KEY_B = 107
GS_KEY_UP = 273

class First :
    def __init__(self) :
        self.width = 320
        self.height = 240 = 0.2
        self.event = None

    def draw(self, screen) :
        screen.blit(pygame.font.Font(None, 24).render("Hello world!", 1, THECOLORS["black"]), (10, 10))
        screen.blit(pygame.font.Font(None, 24).render("You pressed: %s" % self.event, 1, THECOLORS["black"]), (10, 50))

    def run(self) :
        screen = pygame.display.set_mode((0, 0), pygame.FULLSCREEN)
        clock = pygame.time.Clock()

        running = True
        while running :
            for event in pygame.event.get():
                if event.type == QUIT:
                    running = False
                elif event.type == KEYDOWN :
                    self.event = event.key
                    if event.key == GS_KEY_MENU :
                        running = False
            clock.tick(1 /

if __name__ == "__main__" :
    game = First()

Then create an entrance shell “” in the launcher of GameShell.

(first) cpi@clockworkpi:~$ cd launcher/Menu/GameShell
(first) cpi@clockworkpi:~$ vi

The content of “” should be like this.

#! /bin/bash

source activate first
python ~/games/first_game/

You can also make an icon for the new game, say a png picture “First.png”, and put it into “~/launcher/skin/default/Menu/GameShell”.

Reload the UI, and now you should see a new app named “First” in the launcher. Enter it, you will see “Hello world!” followed by a promotion to tell you the code of the last pressed key. If you followed exactly what are given in “”, then you can exit the first game and back to the launcher by pressing the button “MENU” on the GameShell.

That’s all. Happy coding!

As there are limits on the number of links, you have to manually replace the slash after “https” to “://”

[1] https/
[2] https/
[3] https/

屏幕快照 2020-07-11 下午9.32.02