Confused by module path for kivy.garden.graph

1,374 views
Skip to first unread message

David Aldrich

unread,
Jul 31, 2015, 4:18:17 AM7/31/15
to Kivy users support
Hi

I use kivy.garden.graph in my Kivy 3.4 app, which I develop on Windows:

from kivy.garden.graph import Plot, Graph, MeshLinePlot, MeshStemPlot, LinePlot

kivy.garden is installed in my user directory and I see

"C:\Users\<username>\.kivy\garden\garden.graph\__init__.py"

The app runs fine, but I run into problems generating documentation for the app using Sphinx. In the Sphinx conf.py file I specify:

sys.path.insert(0, "c:\\users\<username>\\.kivy\\garden\\garden.graph")

but when I run 'make html' to generate the documentation I see:

  File "C:\gui\main.py", line 56, in <module>
    import mygraph
  File "C:\gui\mygraph.py", line 23, in <module>
    from kivy.garden.graph import Plot, Graph, MeshLinePlot, MeshStemPlot, LinePlot
  File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
  File "<frozen importlib._bootstrap>", line 2226, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 1191, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 1163, in _load_backward_compatible
KeyError: 'kivy.garden.graph'

Shorter versions of the .kivy path give similar errors e.g.:

sys.path.insert(0, "c:\\users\<username>\\.kivy\\garden")

My knowledge of Python modules and search paths is basic. Is the problem something to do with the fact that garden.graph just contains __init__.py and has no file such as graph.py?

Any help for how to fix this would be appreciated as it is breaking my documentation generation process.

Best regards

David


Bill Janssen

unread,
Aug 3, 2015, 3:46:58 PM8/3/15
to Kivy users support
Really a Sphinx issue, perhaps.  The thing is that kivy.garden plays games with the import machinery in order to do its import.  It builds its own importer class and puts it on sys.meta_path.  I think the right thing to do is to not put anything in the Sphinx conf.py file.  kivy.garden already knows where to look.  The key thing with Sphinx is to make sure it calls "kivy" instead of "python".

Bill

Yoel Koenka

unread,
Aug 7, 2015, 4:17:22 PM8/7/15
to Kivy users support
Hi Bill,
Can you write how to make sure Sphinx is using "kivy" instead of "python"?
I'm also having issues with Sphinx in my app, exactly with kivy-garden modules.

Thanks a lot!
Joel

Bill Janssen

unread,
Aug 9, 2015, 4:31:59 PM8/9/15
to Kivy users support
I don't know the answer to that, sorry.  You'll have to look at the Sphinx documentation.

Bill

Bill Janssen

unread,
Aug 9, 2015, 4:35:00 PM8/9/15
to Kivy users support
You could look at http://stackoverflow.com/questions/8015225/how-to-force-sphinx-to-use-python-3-x-interpreter,
which seems to imply that "make html PYTHON=<path-to-kivy>" would work.  Or, if you can install Sphinx with pip, you could try "kivy -m pip install sphinx".  Lots of possibilities there.

Bill

On Friday, August 7, 2015 at 1:17:22 PM UTC-7, Yoel Koenka wrote:

David Aldrich

unread,
Aug 17, 2015, 10:53:38 AM8/17/15
to Kivy users support
I tried:

make html PYTHON="C:\Kivy-1.9.0-py3.4-win32-x64\Python34\python.exe"

but I still get the same error.

Best regards

David

Thomas Chen

unread,
Apr 2, 2016, 10:28:42 PM4/2/16
to Kivy users support
In case you're still having problems, I had the exact same problem with the same error but with kivy.garden.contextmenu, but I managed to fix it.

Here's what I did:
1. Add this to conf.py

sys.path.insert(0, os.path.abspath("path/to/libs/garden/garden.contextmenu"))
2. Change all my imports from

import kivy.garden.contextmenu
to

import context_menu
3. Also, to make sure my app still runs with these imports, had to add the line from step 1 to my app.


On Friday, August 7, 2015 at 1:17:22 PM UTC-7, Yoel Koenka wrote:
Reply all
Reply to author
Forward
0 new messages