1

os : linux(ubuntu 16.04 LTS, 64-bit) python_version : 3.6.3

  • Using virtualenv.
  • I tried to install many version of kivy with many different versions of cython but always i got same error which is like below.
  • After giving "pip install kivy" this install some packages: certifi (2017.11.5) chardet (3.0.4) Cython (0.26) docutils (0.14) idna (2.6) Kivy-Garden (0.1.4) pip (9.0.1) Pygments (2.2.0) requests (2.18.4) setuptools (38.4.0) urllib3 (1.22) wheel (0.30.0)
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/tmp/pip-build-c8ofsvs6/kivy/kivy/include -I/usr/include/python3.6m -I/home/ubuntu/venv/include/python3.6m -c /tmp/pip-build-c8ofsvs6/kivy/kivy/_event.c -o

build/temp.linux-x86_64-3.6/tmp/pip-build-c8ofsvs6/kivy/kivy/_event.o /tmp/pip-build-c8ofsvs6/kivy/kivy/_event.c:4:20: fatal error: Python.h: No such file or directory compilation terminated. error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

  ----------------------------------------
  Failed building wheel for kivy
  Running setup.py clean for kivy
Failed to build kivy
Installing collected packages: kivy
  Running setup.py install for kivy ... error
    Complete output from command /home/ubuntu/venv/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-c8ofsvs6/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-vcdy_iv_-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/ubuntu/venv/include/site/python3.6/kivy: Using distutils

and last

>     > Detected compiler is unix
>     >     skipping '/tmp/pip-build-c8ofsvs6/kivy/kivy/_event.c' Cython extension (up-to-date)
>     >     building 'kivy._event' extension
>     >     creating build/temp.linux-x86_64-3.6
>     >     creating build/temp.linux-x86_64-3.6/tmp
>     >     creating build/temp.linux-x86_64-3.6/tmp/pip-build-c8ofsvs6
>     >     creating build/temp.linux-x86_64-3.6/tmp/pip-build-c8ofsvs6/kivy
>     >     creating build/temp.linux-x86_64-3.6/tmp/pip-build-c8ofsvs6/kivy/kivy
>     >     x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/tmp/pip-build-c8ofsvs6/kivy/kivy/include -I/usr/include/python3.6m -I/home/ubuntu/venv/include/python3.6m -c /tmp/pip-build-c8ofsvs6/kivy/kivy/_event.c -o
>     > build/temp.linux-x86_64-3.6/tmp/pip-build-c8ofsvs6/kivy/kivy/_event.o
>     >     /tmp/pip-build-c8ofsvs6/kivy/kivy/_event.c:4:20: fatal error: Python.h: No such file or directory
>     >     compilation terminated.
>     >      error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
>     >     
>     >     ---------------------------------------- Command "/home/ubuntu/venv/bin/python3 -u -c "import setuptools,
>     > tokenize;__file__='/tmp/pip-build-c8ofsvs6/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-vcdy_iv_-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/ubuntu/venv/include/site/python3.6/kivy" failed with error code
>     > 1 in /tmp/pip-build-c8ofsvs6/kivy/
  • I have also tried with cython 0.25.2
user378625
  • 31
  • 1
  • 5
  • try to type in your command-line `sudo apt update` and then `sudo apt install build-essential`. Also it's important to use Cython 25 here, I had similar problem, and it cannot run with newer Cython. – Qback Jan 16 '18 at 08:52
  • It says that build-essential is already the newest version and i am using Cython (0.25.2) when i give command pip install cython==0.25 it gives errors while setup.py but with pip install cython==0.25 it works – user378625 Jan 16 '18 at 08:55
  • I don't understand. Are you able to `pip install cython==0.25`? Does Kivy work then? – Qback Jan 16 '18 at 09:00
  • i am able to install cython0.25.2 with command pip install cython==0.25.2 but not the version 0.25 and kivy doesn't work with cython (0.25.2) pip install cython==0.25.2 work. pip install cython==0.25 do no t work – user378625 Jan 16 '18 at 09:02

3 Answers3

2

Ok now i figured this issue. This is because of pip cache packages installation i had cython and kivy broken packages in cache due to this every time instead of download a new one pip uses cache which​ has already broken. And now how did these packages broken because of switching python default version sudo update-alternatives --config python3 here i had set python3.6 default and downloaded all packages but some internal working of ubuntu (don't know) do not realy support python3.6 it supports python3.5 due to this download packages currept and goes to cache and when i switch to python3.5 ubuntu works pretty fine but packages had broken.

user378625
  • 31
  • 1
  • 5
1

Instead of pip try apt:

 sudo add-apt-repository ppa:kivy-team/kivy
 sudo apt-get update
 sudo apt-get install python-kivy # or python3-kivy if you're using python3
Mehdi Nellen
  • 141
  • 3
0

Try to install pip install cython==0.25.0 and then install all the requirements from Kivy official install intructions.

It's possible that you can use newer version of cython, but last time when I tried with cython 0.26 and kivy 1.10 I had to downgrade cython.

Qback
  • 1,123
  • 1
  • 8
  • 13
  • pip install cython==0.25.0 gives error – user378625 Jan 16 '18 at 09:42
  • 'x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.6m -c /tmp/pip-build-10sxp8ib/cython/Cython/Plex/Scanners.c -o build/temp.linux-x86_64-3.6/tmp/pip-build-10sxp8ib/cython/Cython/Plex/Scanners.o /tmp/pip-build-10sxp8ib/cython/Cython/Plex/Scanners.c:15:20: fatal error: Python.h: No such file or directory compilation terminated. error: command 'x86_64-linux-gnu-gcc' failed with exit status 1' – user378625 Jan 16 '18 at 09:43
  • that's strange.. Did you install those requirements? They are crucial here. You can also try to uninstall cython and then install it again in 0.25 – Qback Jan 16 '18 at 09:43
  • r u taking about: sudo apt-get install -y \ python-pip \ build-essential \ git \ python \ python-dev \ ffmpeg \ libsdl2-dev \ libsdl2-image-dev \ libsdl2-mixer-dev \ libsdl2-ttf-dev \ libportmidi-dev \ libswscale-dev \ libavformat-dev \ libavcodec-dev \ zlib1g-dev – user378625 Jan 16 '18 at 09:44
  • yes, that's what I'm talking about. – Qback Jan 16 '18 at 09:45
  • but it's done i have installed all of these and one more thing (cython version 0.25.2 can be install but not 0.25.0) – user378625 Jan 16 '18 at 09:45
  • do you know that i am using virtualenv ? – user378625 Jan 16 '18 at 09:57
  • Yes, I know. Do you type `. bin/activate` to start using virtualenv before calling `pip` instructions? You can also try with the newest Cython (0.27.x) but I don't know if it'll work – Qback Jan 16 '18 at 09:59
  • yes i have installed cython 0.27 but i think problem is something else let's take a look : * /tmp/easy_install-535vh05g/Cython-0.25/Cython/Plex/Scanners.c:15:20: fatal error: Python.h: No such file or directory compilation terminated. error: Setup script exited with error: command 'x86_64-linux-gnu-gcc' failed with exit status 1 i noticed many times with installing some packages with pip i got error: * Command "python setup.py egg_info" failed with error code 1 * and related to x86_64-linux-gnu-gcc – user378625 Jan 16 '18 at 10:19
  • type `pip list` and paste output here please – Qback Jan 16 '18 at 10:26
  • `DEPRECATION: The default format will switch to columns in the future. You can use --format=(legacy|columns) (or define a format=(legacy|columns) in your pip.conf under the [list] section) to disable this warning. certifi (2017.11.5) chardet (3.0.4) Cython (0.27.3) docutils (0.14) idna (2.6) Kivy-Garden (0.1.4) pip (9.0.1) Pygments (2.2.0) requests (2.18.4) setuptools (38.4.0) urllib3 (1.22) wheel (0.30.0) – user378625 Jan 16 '18 at 10:32
  • try that... `sudo apt-get install python-dev # for python2.x installs` `sudo apt-get install python3-dev # for python3.x installs` – Qback Jan 16 '18 at 10:48
  • `Reading package lists... Done Building dependency tree Reading state information... Done python3-dev is already the newest version (3.5.1-3). 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.` – user378625 Jan 16 '18 at 10:49
  • I don't know. I can't help you. Maybe you have pip broken. Here's topic with similar error: https://stackoverflow.com/questions/35991403/python-pip-install-gives-command-python-setup-py-egg-info-failed-with-error-c – Qback Jan 16 '18 at 10:55
  • you must be know that i am using `python 3.6.3` – user378625 Jan 16 '18 at 10:56
  • so maybe try to create virtualenv using python2. Or try use `pip3` instead of `pip` – Qback Jan 16 '18 at 11:01