Installing Latest Kivy on a Python 3.6 Virtual Environment in Ubuntu 18.04

636 views
Skip to first unread message

Jan Magnus Røkke

unread,
May 28, 2018, 9:45:48 AM5/28/18
to Kivy users support
Hi. Is there a complete guide or similar for setting up a Kivy development environment with the latest Kivy version for Python 3.6 on a virtual environment on Ubuntu. I have tried now for many days, but I am running into obstacles every step of they way and I am soon giving up :/ My goal is to have an development environment on Ubuntu for developing Android applications with Kivy. However, I am quite a novice all of the above.

Hildeberto Abreu Magalhães

unread,
May 29, 2018, 6:41:33 AM5/29/18
to Kivy users support
Working for making better, but works yet. https://github.com/pug-pb/pyne2018app

Jan Magnus Røkke

unread,
Jun 4, 2018, 2:37:45 AM6/4/18
to Kivy users support
I have tried following the Kivy guide for installation on Linux, but I keep getting the following error:


error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
 
 ----------------------------------------
Command "/home/seawolf/Development/env/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-e7homhct/kivy/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-qhp78tus-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/seawolf/Development/env/include/site/python3.6/kivy" failed with error code 1 in /tmp/pip-build-e7homhct/kivy/



Attached is the complete log. Any suggestions is highly appreciated.

kivy_install_log.txt

ZenCODE

unread,
Jun 4, 2018, 3:34:17 PM6/4/18
to Kivy users support
Looks like a cython issue. I see you are using 0.25.2. Try 0.26.1? Or 27.3? Or 28.3? Any change in the message at least?

Hildeberto Abreu Magalhães

unread,
Jun 4, 2018, 8:27:47 PM6/4/18
to Kivy users support
Try downgrade, cython==0.23. Works to me.

Jan Magnus Røkke

unread,
Jun 5, 2018, 2:15:14 AM6/5/18
to kivy-...@googlegroups.com
Thanks for your suggestions. I tried with using both Cython 0.23 and 0.26.1, however, it seems I get the same error message still. 

Kivy install with Cython 0.23

     error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
    
    ----------------------------------------
Command "/home/seawolf/Development/env/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-iiv86cus/kivy/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-545djw2n-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/seawolf/Development/env/include/site/python3.6/kivy" failed with error code 1 in /tmp/pip-build-iiv86cus/kivy/


Kivy install with Cython 0.26.1

     error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
    
    ----------------------------------------
Command "/home/seawolf/Development/env/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-e2dkp32s/kivy/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-jpy3tfds-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/seawolf/Development/env/include/site/python3.6/kivy" failed with error code 1 in /tmp/pip-build-e2dkp32s/kivy/

The pip-build-.... refereed to in the command seems different though. I don't know if it is of any relevance. 

Before attempting to install Kivy in the virtual environment i made sure that the following dependencies were installed on Ubuntu.
sudo apt-get install -y \
    python-pip \
    build-essential \
    git \
    python3 \
    python3-dev \
    ffmpeg \
    libsdl2-dev \
    libsdl2-image-dev \
    libsdl2-mixer-dev \
    libsdl2-ttf-dev \
    libportmidi-dev \
    libswscale-dev \
    libavformat-dev \
    libavcodec-dev \
    zlib1g-dev

--
You received this message because you are subscribed to the Google Groups "Kivy users support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
kivy_install_log_cython_0.26.1.txt
kivy_install_log_cython_0.23.txt

John Evan Dizaro

unread,
Jun 5, 2018, 10:31:03 AM6/5/18
to kivy-...@googlegroups.com
I'm having the same problem as you.
I tried everything and it did not work for me.




To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Kivy users support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
John Evan Dizaro 
Desenvolvimento de Sistema Computacionais - Linux, MSWindows
Celular (41) 99540-4240

°v° NÃO USE DROGAS,
/(_)\ USE GNU/LINUX
 ^ ^

Diego

unread,
Jun 5, 2018, 8:38:18 PM6/5/18
to Kivy users support
I had similar issues when trying to install latest kivy on virtual environment using Debian 9. The solution was to install kivy==1.9.1 together with cython==0.23
It seems to be an issue for kivy 1.10.0 with latest Ubuntu working inside a virtual environment.
Hope this helps.

Jan Magnus Røkke

unread,
Jun 6, 2018, 1:52:33 AM6/6/18
to kivy-...@googlegroups.com
Attempted with kivy==1.9.1 together with cython==0.23, but I get the same issue it seems. Here are the steps I have been following:

1. Installed Ubuntu 18.04 on Virtual Machine using VMWare Workstation.
2. Run apt-get update, and apt-get upgrade.
3. Installed the following (python 3.6.5 already installed on Ubuntu).
sudo apt-get instal -y \
    python-pip \
    build-essential \
    git \
    ffmpeg \
    libsdl2-dev \
    libsdl2-image-dev \
    libsdl2-mixer-dev \
    libsdl2-ttf-dev \
    libportmidi-dev \
    libswscale-dev \
    libavformat-dev \
    libavcodec-dev \
    zlib1g-dev
4. Created virtual environment:
sudo apt-get install python3-venv
mkdir kivyenv
cd kivyenv
python3 -m venv env
source env/bin/activate
5. Installed Cython and Wheels
pip install Cython==0.23
pip install wheel
6. Installed Kivy
pip install kivy==1.91

--
You received this message because you are subscribed to the Google Groups "Kivy users support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.
kivy_1.9.1_install_log_cython_0.23.txt

Hildeberto Abreu Magalhães

unread,
Jun 6, 2018, 6:27:09 AM6/6/18
to Kivy users support
I don't analyze your described installation, but, this script below works fine for me:

obs.:

* I prefer use Miniconda in virtualenv
* I prefer install kivy from source


In this repository I'm working in app for conferences. If you like help, take my pleasure.

---------------------------------------------------------------------------

#!/usr/bin/env bash
clear
sudo apt update && sudo apt full-upgrade -y && sudo apt autoremove -y
read -p "Press enter to continue"

clear


# to package for android with buildozer below is necessary
sudo dpkg --add-architecture i386
sudo apt install -y libncurses5:i386 libstdc++6:i386 libgtk2.0-0:i386 \
libpangox-1.0-0:i386 libpangoxft-1.0-0:i386 libidn11:i386 zlib1g:i386

sudo apt install -y openjdk-8-jdk
sudo apt install -y ccache adb apksigner

## system dependencies
sudo apt install -y build-essential git python-dev python3-dev libssl-dev \
libcups2-dev libcairo2-dev libsdl2-dev libsdl2-image-dev \
libsdl2-mixer-dev libsdl2-ttf-dev libportmidi-dev libswscale-dev \
libavformat-dev libavcodec-dev zlib1g-dev ffmpeg libsmpeg-dev \
libgstreamer1.0 gstreamer1.0-plugins-base gstreamer1.0-plugins-good \
docutils-common docutils-doc sgml-base xclip xml-core xsel \
python-lxml python3-lxml xvfb

read -p "Press enter to continue"

clear
# get and install miniconda if not exists (not use sudo)
cd
if [ ! -f ./Miniconda3-latest-Linux-x86_64.sh ]; then
wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh
fi

chmod +x Miniconda3-latest-Linux-x86_64.sh

#
run installer, agree with the terms, set default location and answer "yes" to update PATH in .bashrc
./Miniconda3-latest-Linux-x86_64.sh

# update conda and create kivy virtualenv
~/miniconda3/bin/conda update --all
~/miniconda3/bin/conda create -n kivy3 pip setuptools requests

read -p "Press enter to continue"

clear
source ~/miniconda3/bin/activate kivy3
pip install cython==0.23 pillow==4.3.0

# to my app, need this
# cd kpyconf/
# pip install -r need-install.txt

read -p "Press enter to continue"

clear
# download kivy source code
cd
wget https://github.com/kivy/kivy/archive/master.zip
unzip master.zip

# install from source
cd kivy-master
python setup.py install
pip install kivy-garden

read -p "Press enter to continue"

clear
cd ~/kivy-master/examples/demo/showcase/
python main.py

# Optional - install PyCharm CE
# wget https://download.jetbrains.com/python/pycharm-community-2018.1.2.tar.gz
# extract at /home/develop



-----------------------------------------------------------------------------------------------------------------------------------

ZenCODE

unread,
Jun 6, 2018, 3:53:28 PM6/6/18
to Kivy users support
@Jan Magnus Røkke

Have you tried building use the latest dev version i.s.o. master? This issue seems to have been fixed?

Jan Magnus Røkke

unread,
Jun 11, 2018, 6:31:45 AM6/11/18
to kivy-...@googlegroups.com
@Hildeberto Abreu Magalhães

Thanks for your reply. However, there is just to much in there I do not understand. I am quite a newbie in the Linux environment in general. What do you mean when you say "install kivy from source"? 

I am confused about all the various ways (sources/command) there seems to be to install kivy (and other stuff) on Linux. E.g. PPA, daily-build, nightly-build, dev branch, etc, using python3 -m pip ..., apt ...., apt-get .... python-kivy / kivy / kivy-<version>. I do not understand the difference between them, nor the need for all the options. If anyone could explain this to me or point me to some explanation of this it would be very helpful.

@ZenCODE

I attempted to install using, python3 -m pip install git+https://github.com/kivy/kivy.git

I assume this is the dev master you were referring to? It actually seems like it worked. I have not tested it yet, but the installation went through without any errors. Are there any drawbacks using this dev version vs. official releases?

ZenCODE

unread,
Jun 12, 2018, 10:42:40 AM6/12/18
to Kivy users support
Good stuff. Yes, that is exactly what I was referring to. And building as you did is "building from source code". The drawback of using master is that you are using the bleeding edge kivy, so not all the changes and additions are thoroughly tested, so it's slightly more risky. The advantages is that is contains the latest fixes and features. So it's a slight risk if you are facing deployment.

In my experience, master is pretty stable anyway, but I tend not to need the latest features and have quite specific use cases. If you are still at the development phases, I would say master is fine, especially as it solves your issues...:-)

Reply all
Reply to author
Forward
0 new messages