Ticket #350 (closed defect: fixed)

Opened 4 years ago

Last modified 4 years ago

Pippy: Python path set improperly

Reported by: sascha_silbe Owned by: brian
Priority: Unspecified by Maintainer Milestone: Unspecified by Release Team
Component: Pippy Version: Git as of bugdate
Severity: Unspecified Keywords: patch
Cc: Distribution/OS: Unspecified
Bug Status: Assigned

Description

The slideshow example in Pippy doesn't work:

Traceback (most recent call last):

File "/home/sugar/.sugar/default/org.laptop.Pippy/tmp/pippy_app.py", line 7, in <module>

from pippy import query

File "/home/sugar/sugar-jhbuild/install/share/sugar/activities/Pippy.activity/library/pippy/query.py", line 22, in <module>

from sugar.datastore import datastore

ImportError: No module named sugar.datastore

Attachments

pippy-pythonpath.diff Download (0.6 KB) - added by sascha_silbe 4 years ago.
append original PYTHONPATH

Change History

Changed 4 years ago by erikos

Which version of sugar-datastore are you using?

Changed 4 years ago by sascha_silbe

Everything built from sugar-jhbuild as of today.

Changed 4 years ago by tomeu

that module is in sugar-toolkit, wonder how pippy can start but that example cannot.

Are you running it after running './sugar-jhbuild shell'?

Changed 4 years ago by sascha_silbe

that module is in sugar-toolkit, wonder how pippy can start but that example cannot.

Is Pippy somehow fiddling with the Python search path?

"print sys.path" gives the following inside Pippy:

['/home/sugar/.sugar/default/org.laptop.Pippy/tmp', '/home/sugar/.sugar/default/org.laptop.Pippy/tmp', '/home/sugar/sugar-jhbuild/install/share/sugar/activities/Pippy.activity/library', '/usr/lib/python2.5', '/usr/lib/python2.5/plat-linux2', '/usr/lib/python2.5/lib-tk', '/usr/lib/python2.5/lib-dynload', '/usr/local/lib/python2.5/site-packages', '/usr/lib/python2.5/site-packages', '/usr/lib/python2.5/site-packages/Numeric', '/usr/lib/python2.5/site-packages/gst-0.10', '/var/lib/python-support/python2.5', '/var/lib/python-support/python2.5/gtk-2.0']

Inside "sugar-jhbuild shell" it is:

['', '/home/sugar/sugar-jhbuild/install/lib64/python2.5/site-packages/gtk-2.0', '/home/sugar/sugar-jhbuild/install/lib/python2.5/site-packages', '/home/sugar/sugar-jhbuild/install/lib64/python2.5/site-packages', '/usr/lib/python2.5', '/usr/lib/python2.5/plat-linux2', '/usr/lib/python2.5/lib-tk', '/usr/lib/python2.5/lib-dynload', '/usr/local/lib/python2.5/site-packages', '/usr/lib/python2.5/site-packages', '/usr/lib/python2.5/site-packages/Numeric', '/usr/lib/python2.5/site-packages/gst-0.10', '/var/lib/python-support/python2.5', '/var/lib/python-support/python2.5/gtk-2.0']

As you see, two paths below the sugar-jhbuild install directory are missing.

Are you running it after running './sugar-jhbuild shell'?

I'm running it from inside sugar-emulator. Is it possible to start Activities outside of sugar / sugar-emulator or did I misunderstand your question?

Changed 4 years ago by sascha_silbe

I've found the code and am actually surprised it would work on any system:

pippy_app.py:go_button_cb()

        self._pid = self._vte.fork_command \
                    (command="/bin/sh",
                     argv=["/bin/sh", "-c",
                           "python %s; sleep 1" % pippy_app_name],
                     envv=["PYTHONPATH=%s/library" % get_bundle_path()],
                     directory=get_bundle_path())

As you see it sets PYTHONPATH to a single directory. This will override the PYTHONPATH set by sugar-jhbuild. Only built-in (i.e. system) paths and the Pippy library path will work. That's why pippy, os, sys etc. can be used, but nothing from Sugar.

Changed 4 years ago by sascha_silbe

append original PYTHONPATH

Changed 4 years ago by sascha_silbe

  • keywords patch added
  • distribution changed from Ubuntu to Unspecified
  • status_field changed from Unconfimed to New

With the patch, it loads fine. Complains about no photos being found (though I just downloaded one and verified the MIME type matched), but that should be a different issue.

Changed 4 years ago by sascha_silbe

  • summary changed from Pippy: Slideshow: Python module sugar.datastore not found to Pippy: Python path set improperly

Changed 4 years ago by brian

  • owner changed from lfaraone to brian
  • status changed from new to assigned
  • status_field changed from New to Assigned

Will apply patch

Changed 4 years ago by sascha_silbe

Any news on this?

Changed 4 years ago by brian

  • status changed from assigned to closed
  • resolution set to fixed

In pippy v31

Note: See TracTickets for help on using tickets.