Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#350 closed defect (fixed)

Pippy: Python path set improperly

Reported by: sascha_silbe Owned by: brian
Priority: Unspecified by Maintainer Milestone: Unspecified
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 (1)

pippy-pythonpath.diff (597 bytes) - added by sascha_silbe 12 years ago.
append original PYTHONPATH

Download all attachments as: .zip

Change History (11)

comment:1 Changed 12 years ago by erikos

Which version of sugar-datastore are you using?

comment:2 Changed 12 years ago by sascha_silbe

Everything built from sugar-jhbuild as of today.

comment:3 Changed 12 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'?

comment:4 Changed 12 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?

comment:5 Changed 12 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 12 years ago by sascha_silbe

append original PYTHONPATH

comment:6 Changed 12 years ago by sascha_silbe

  • Bug Status changed from Unconfimed to New
  • Distribution/OS changed from Ubuntu to Unspecified
  • Keywords patch added

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.

comment:7 Changed 12 years ago by sascha_silbe

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

comment:8 Changed 12 years ago by brian

  • Bug Status changed from New to Assigned
  • Owner changed from lfaraone to brian
  • Status changed from new to assigned

Will apply patch

comment:9 Changed 12 years ago by sascha_silbe

Any news on this?

comment:10 Changed 12 years ago by brian

  • Resolution set to fixed
  • Status changed from assigned to closed

In pippy v31

Note: See TracTickets for help on using tickets.