(This may be a duplicate of an unanswered question at How do I Install Kivy for python 3.4 on my raspberry? Is that possible? , but I'd like to add some details to this.)

I have followed the default instructions for Manual installation (On Raspbian Jessie) at https://kivy.org/docs/installation/installation-rpi.html , and Kivy runs ok with Python, only that the version of Python that Kivy works with is 2.7:

[INFO   ] [Kivy        ] v1.9.2.dev0, git-e831904, 20170422  
[INFO   ] [Python      ] v2.7.9 (default, Sep 17 2016, 20:26:04)

Trying to run the code with python3.4 code.py of course results in

Traceback (most recent call last):
  File "code.py", line 5, in <module>
    from kivy.app import App
ImportError: No module named 'kivy'

suggesting that Python 3.4 isn't set up with Kivy.

I would be extremely grateful for pointers to how I could either

  1. set up Kivy for Python 3.4 (as in other question), or
  2. redirect library for Python 3.4 so as to have it work with the Kivy installed in the default (2.7) Python library somehow.

(2. may be possible with PYTHONPATH ... ? Which I don't see in the default .profile file, so I'm a bit confused...)

  • Okay wait, this may be a way forward: linuxconfig.org/…
    – yybtcbk
    Apr 23, 2017 at 3:44
  • If you think you have found a solution, you can always post it as an answer.
    – Darth Vader
    Apr 23, 2017 at 8:23

1 Answer 1


NOTE 1: this MAY BREAK other software dependent on Python2, so please beware.
EDIT 2 : step 4 onwards should alleviate the possible damage from the temporary switch.
NOTE 3: it may be necessary to install Kivy under Python2 first BEFORE step 1 for this to work properly.

I think I've managed to find a solution for this:

  1. Referring to this page, set default Python to 3.4 (per-user or system-wide, according to your needs):

    How to change from default to alternative Python version on Debian Linux https://linuxconfig.org/how-to-change-from-default-to-alternative-python-version-on-debian-linux

    At this point, python --version should give you Python 3.4.2.

  2. Follow instructions on the regular Kivy Install Page:

    User’s Guide » Installation on Raspberry Pi

  3. Test run a python script with Kivy use, using the python command, and see if the log shows the likes of

    [INFO   ] [Kivy        ] v1.9.2.dev0, git-388651a, 20170423  
    [INFO   ] [Python      ] v3.4.2 (default, Oct 19 2014, 13:31:11)

If you have changed the system-wide default Python, then do the following as well, to minimize any damage to other applications:

  1. Referring to the page in step 1, run

    # update-alternatives --config python

    and select the python2.7 path as your default python.

  2. Check that python --version gives you Python 2.7.9 and that python3 --version gives you Python 3.4.2 at this point.

  3. Test run the script in step 3, but using python3 instead, and check that it works as in step 3.

  • You can do this, but it is A bad idea. You will probably break a lot of existing software which requires Python 2, which is still the standard default. Any script which requires Python3 should specify this (usually with shebang). A better approach would be to fix these. There are quite a lot of posts on this site, and others which explain this in more detail. Incidentally the version of Python3 on my up-to-date Raspbian is 3.6.0
    – Milliways
    Apr 23, 2017 at 7:35
  • @Milliways Thanks for the heads-up. I'm thinking of basing my new project on Kivy+Python3, following the lines that Python 2.x is legacy, Python 3.x is the present and future of the language. I'm thinking of dedicating the specific Raspberry Pi for that purpose, so I'd presume there are close to no other software to break. The only remaining downside is perhaps reduced availability of usable libraries. Would you still recommend against using Python3 as default in this specific case?
    – yybtcbk
    Apr 23, 2017 at 11:29
  • I think Python3 has its problems, although I use it for new code. Depending on the impact this has on system code (a lot is, and will remain Python2) it may be OK, but it is better to explicitly code which and follow pep-0394. I believe Arch has python3 as default, but my Mac doesn't even have a system supplied Python3.
    – Milliways
    Apr 23, 2017 at 11:40
  • @Milliways I've added a warning at the top of the answer to warn others of this fact. As for the Python 3.6.0 version--I'll look into updating this as well.
    – yybtcbk
    Apr 23, 2017 at 11:40
  • @Milliways when you say "impact on system code", are you implying the Raspbian and the basic functions may be affected by the switch above? As for pep-0394, I agree it's best practice to keep code portable, but I'm not sure I'll want to be that strict as regards coding this project, so will probably end up writing 2.x or 3.x dependent code...
    – yybtcbk
    Apr 23, 2017 at 11:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.