Guide: Kivy and Python Tools for Visual Studio

9,399 views
Skip to first unread message

Cam Jackson

unread,
Nov 9, 2013, 10:55:46 AM11/9/13
to kivy-...@googlegroups.com
Hi everyone,

I posted here a while ago looking for help with Kivy and PyDev, and ended up writing my own guide on how to do it. There have since been some people requesting a similar guide for Python Tools for Visual Studio, so I've written one up for that too. So PTVS users, go here: http://www.ocularsoftware.com/2013/11/how-to-use-python-tools-for-visual-studio-to-develop-and-run-kivy-applications/.

Hope that helps someone :)

ZenCODE

unread,
Nov 9, 2013, 5:05:02 PM11/9/13
to kivy-...@googlegroups.com
Thanks Cam! Your Pydev post helped me a lot ;-)

It seems like there is a need for IDE setup guides. I've added that to my "todo" list.

https://groups.google.com/forum/#!topic/kivy-users/n7c3thksnzg

Also added a post for adding kv syntax highlighting for pycharm.

https://groups.google.com/forum/#!topic/kivy-dev/FBtDU_XNp9o

Your posts really helped with Eclipse, so thanks again. Eclipse is probably still my first choice... although PyCharm is really sexy...? ;-)

Cheers

Akshay Arora

unread,
Nov 11, 2013, 5:39:44 AM11/11/13
to kivy-...@googlegroups.com
@Zencode maybe we should consolidate the info in one place. wiki sounds like a good place to start this https://github.com/kivy/kivy/wiki/Setting-up-kivy-with-various-popular-IDE


--
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/groups/opt_out.

ZenCODE

unread,
Nov 11, 2013, 7:07:14 AM11/11/13
to kivy-...@googlegroups.com
@qua-non: Yup, agreed. I though to describe the core principles there (environment variables, venv vs. installed python) together with a generic "setup your interpreter" process, then link to IDE specific setup's. Including them all might be too much?

Akshay Arora

unread,
Nov 11, 2013, 9:46:27 AM11/11/13
to kivy-...@googlegroups.com
Feel free to adjust the information , I only added the links as stubs. Would be great if you could improve the content.
I agree that we should have sub sections like setting up environment variables, syntax highliting...etc.


On Mon, Nov 11, 2013 at 5:37 PM, ZenCODE <zenkey....@gmail.com> wrote:
@qua-non: Yup, agreed. I though to describe the core principles there (environment variables, venv vs. installed python) together with a generic "setup your interpreter" process, then link to IDE specific setup's. Including them all might be too much?

--

David Aldrich

unread,
Jan 19, 2015, 5:58:37 AM1/19/15
to kivy-...@googlegroups.com
Hi


Seems to be offline. Is this article archived anywhere else?

Best regards

David

Cam Jackson

unread,
Jan 19, 2015, 7:10:02 AM1/19/15
to kivy-...@googlegroups.com

--
You received this message because you are subscribed to a topic in the Google Groups "Kivy users support" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/kivy-users/tZTuUzUHBwc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to kivy-users+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

David Aldrich

unread,
Jan 19, 2015, 8:17:12 AM1/19/15
to kivy-...@googlegroups.com
Thanks for the links.

David

David Aldrich

unread,
Jan 19, 2015, 10:25:01 AM1/19/15
to kivy-...@googlegroups.com
Hi

I am new to Livy and quite new to Python. I am trying to make a very simple Kivy application run under PTVS 2.1.  I have copied the 'simple paint' example from the Livy tutorial and added the environment settings described by Cam's blog post.  Here is the code:

#!/usr/bin/env python

import os
os.environ['GST_PLUGIN_PATH'] = 'C:\Kivy-1.8.0-py3.3-win32\gstreamer\lib\gstreamer-1.0'
os.environ['GST_REGISTRY'] = 'C:\Kivy-1.8.0-py3.3-win32\gstreamer\registry.bin'
os.environ['PATH'] = 'C:\Kivy-1.8.0-py3.3-win32\;C:\Kivy-1.8.0-py3.3-win32\Python33;C:\Kivy-1.8.0-py3.3-win32\tools;C:\Kivy-1.8.0-py3.3-win32\Python33\Scripts;C:\Kivy-1.8.0-py3.3-win32\gstreamer\bin;C:\Kivy-1.8.0-py3.3-win32\MinGW\bin;C:\ProgramData\Oracle\Java\;%PATH%'

from kivy.app import App
from kivy.uix.floatlayout import FloatLayout
from kivy.factory import Factory
from kivy.properties import ObjectProperty
from kivy.uix.popup import Popup

from kivy.app import App
from kivy.uix.widget import Widget
from kivy.graphics import Color, Ellipse


class MyPaintWidget(Widget):

    def on_touch_down(self, touch):
        with self.canvas:
            Color(1, 1, 0)
            d = 30.
            Ellipse(pos=(touch.x - d / 2, touch.y - d / 2), size=(d, d))


class MyPaintApp(App):

    def build(self):
        return MyPaintWidget()


if __name__ == '__main__':
    MyPaintApp().run()

when I run it under PTVS I get the following error:

File "C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\Extensions\Microsoft\Python Tools for Visual Studio\2.1\visualstudio_py_util.py", line 82, in exec_code
    exec(code_obj, global_variables)
  File "C:\Users\daldrich\Work\Kivy\module1.py", line 9, in <module>
    from kivy.uix.floatlayout import FloatLayout
ImportError: No module named 'kivy'
Press any key to continue 

I have set set up the kivy environment for PTVS as described in the blog post.

What setting am I likely to have done wrong that would give the error "No module named 'kivy'" ?

Best regards

David

David Aldrich

unread,
Jan 19, 2015, 12:08:59 PM1/19/15
to kivy-...@googlegroups.com
I just noticed that kivy.bat sets:

PYTHONPATH:
C:\Kivy-1.8.0-py3.3-win32\kivy;

So do I need to add:

os.environ['PYTHONPATH'] = r"C:\Kivy-1.8.0-py3.3-win32\Kivy"

to my module?

(sorry about the typos in my previous email).

Best regards

David

David Aldrich

unread,
Jan 20, 2015, 5:56:00 AM1/20/15
to kivy-...@googlegroups.com
Hi

I'm still struggling to make PTVS work with Kivy. As I wrote above, I was getting error:

ImportError: No module named 'kivy'

There seems to me to be two ways of solving this:

1) Set PYTHONPATH:

PYTHONPATH=C:\Kivy-1.8.0-py3.3-win32\kivy;

However, that didn't work for me.

2) Set Properties > Debug > Search Path to:

C:\Kivy-1.8.0-py3.3-win32\Kivy

That did work but I then get a different error:

No module named 'Image'

at line 10 of img_pil.py

Please can anyone advise me how to fix these problems?

Best regards

David

Ondřej Chrastina

unread,
Jan 25, 2015, 4:35:11 PM1/25/15
to kivy-...@googlegroups.com
Hi, I have exactly the same problem. 

Dne úterý 20. ledna 2015 11:56:00 UTC+1 David Aldrich napsal(a):

ZenCODE

unread,
Jan 25, 2015, 4:57:09 PM1/25/15
to kivy-...@googlegroups.com
Setting the debug search path should not be necessary. Setting up the PYTHONPATH variables should be enough.  Start with the most basic app that just displays a  label. Then take it from there. Does that work?

Cheers


David Aldrich

unread,
Jan 26, 2015, 10:45:57 AM1/26/15
to kivy-...@googlegroups.com

On Sunday, January 25, 2015 at 9:57:09 PM UTC, ZenCODE wrote:
Setting the debug search path should not be necessary. Setting up the PYTHONPATH variables should be enough.  Start with the most basic app that just displays a  label. Then take it from there. Does that work?

Cheers

 
Hi

I asked about using PYTHONPATH on the PTVS forum:


The answer was:

See this page for an explanation of why we block the value of PYTHONPATH and how to use Search Paths through Solution Explorer. 

So, it seems, that the correct way to use Kivy with PTVS is to use search paths, not PYTHONPATH.  A search path worked for me.  Perhaps this info could be added to the PTVS Guide for Kivy?

David

Francisco Ponce

unread,
May 7, 2023, 11:12:51 AM5/7/23
to Kivy users support
Hello Everyone

How can I make the KV file be read by Pycharm in a smart way.

It already is working, but doesn't allow me to do smart folding/unfolding and see the different identations and commands in colors, as do the py file.

Thanks in advance
Happy Coding

ElliotG

unread,
May 20, 2023, 12:40:24 PM5/20/23
to Kivy users support
Reply all
Reply to author
Forward
0 new messages