Kivy + Python3 on OSX environment maintenance

I learned that I could write iOS / Android apps with Python, and tried to improve the environment immediately, but it took a lot of time, so I made a note. Official documentation here.

Required package installation

Various libraries

Kivy depends on pygame, and you need to pre-install the SDL libraries that pygame depends on, and libpng to avoid errors when installing freetype, which sdl_ttf depends on. Must be installed with --universal. It's complicated ...

brew reinstall libpng --universal
brew install sdl sdl_image sdl_mixer sdl_ttf portmidi

Install from source

How to clone the repository and then install it normally

Get the sauce.

git clone --depth 1 -b 1.9.0 --single-branch  https://github.com/kivy/kivy.git
git clone --depth 1 -b 0.21.2 --single-branch https://github.com/cython/cython.git

First, build and install Cython.

cd cython
python3 ./setup.py build
sudo python3 setup.py install

Build and install Kivy as well.

python3 setup.py build_ext --inplace -f
sudo python3 setup.py install

Confirm that it is installed.

pip3 list | grep -e Cython -e Kivy
Cython (0.21.2)
Kivy (1.9.0)

How to specify the repository directly in pip

If you do the following, you can directly specify the repository and install it without git clone each time.

sudo pip3 install git+https://github.com/kivy/[email protected]
sudo pip3 install git+https://github.com/cython/[email protected]

Sample code execution

When I ran the sample code on the Kivy official website, the OS X UI was displayed. With this, I was finally able to stand on the starting line.

#!/usr/bin/env python3
# -*- coding:utf-8 -*-

from kivy.app import App
from kivy.uix.widget import Widget

class PongGame(Widget):
    pass

class PongApp(App):
    def build(self):
        return PongGame()

if __name__ == "__main__":
    PongApp().run()

スクリーンショット 2015-06-20 21.43.04.png

Reference material

Recommended Posts

Kivy + Python3 on OSX environment maintenance
Create an OpenCV3 + python3 environment on OSX
Python + Kivy development on Windows
Build Python environment on Windows
Build python environment on windows
Environment construction of python2 & 3 (OSX)
Python environment construction memo on Windows 10
Installing Kivy on Windows10 64bit Python3.5
Prepare Python development environment on Ubuntu
Anaconda python environment construction on Windows 10
Building a Python environment on Ubuntu
Install python2.7 on windows 32bit environment
Create a Python environment on Mac (2017/4)
Python environment construction memo on Mac
Python development environment construction on macOS
Set up Python environment on CentOS
Create a python environment on centos
Environment construction of python3.8 on mac
Install Python development environment on Windows 10
Build Python 3.8 + Pipenv environment on Ubuntu 18.04
Build a python3 environment on CentOS7
Introduce Python 3.5.2 environment on Amazon Linux
OpenCV3 & Python3 environment construction on Ubuntu
I set the python operating environment on OSX Yosemite (pyenv + pip)
Python 2.7, 3.4, 3.5 extension module build environment on Windows
Python virtual environment and packages on Ubuntu
Create a python environment on your Mac
Steps to install Python environment on Ubuntu
Creating a python virtual environment on Windows
I installed Kivy on a Mac environment
Created Ubuntu, Python, OpenCV environment on Docker
Build Python environment with Anaconda on Mac
Build a Python + OpenCV environment on Cloud9
Python on Windows
Python environment construction
python environment settings
twitter on python3
python windows environment
Environment construction (python)
python on mac
python environment construction
Python --Environment construction
Python environment construction
Python on Windbg
python environment construction
[Note] Python environment construction on rental server "CORESERVER"
Build python environment with pyenv on EC2 (ubuntu)
Build Python3.5 + matplotlib environment on Ubuntu 12 using Anaconda
Simply build a Python 3 execution environment on Windows
Install python package in personal environment on Ubuntu
Build a python environment with ansible on centos6
How to use Python Kivy ④ ~ Execution on Android ~
Build a Python environment on Mac (Mountain Lion)
Build a Python development environment on your Mac
[Venv] Create a python virtual environment on Ubuntu
Set up python Tornado environment on raspbian jessie
[Node-RED] Execute Python on Anaconda virtual environment from Node-RED [Anaconda] [Python]
Put Python 2.7.x on Mac OSX 10.15.5 with pyenv
Build Python3 + flask environment on GCP Compute Engine
Set up a Python development environment on Marvericks
Build a Python environment with OSX El capitan