On Tue, Nov 29, 2016 at 3:26 PM, Ramesh Nachimuthu <rnach...@redhat.com> wrote: > Hi, > > I am trying to run a python script '/sbin/gluster-eventsapi' in vdsm verb > which internally imports some python modules from > /usr/lib/python2.7/site-packages/gluster/cliutils/. But it fails with the > import error. Following error is seen in the supervdsm log. > > > MainProcess|Thread-1::DEBUG::2016-11-28 > 16:54:35,130::commands::93::root::(execCmd) FAILED: <err> = 'Traceback (most > recent call last):\n File "/sbin/gluster-eventsapi", line 25, in <module>\n > from gluster.cliutils.cliutils import (Cmd, execute, node_output_ok, > node_output_notok,\nImportError: No module named cliutils.cliutils\n'; <rc> = > 1 > > > I think the import statement "from gluster.cliutils.cliutils import (Cmd, > execute, node_output_ok, node_output_notok)" in the python script resolves to > '/usr/share/vdsm/gluster' instead of > /usr/lib/python2.7/site-packages/gluster/cliutils. > > I see the following in python sys.path while executing a python script from > vdsm. > > ['/usr/libexec/glusterfs', '/usr/share/vdsm', '/usr/lib64/python27.zip', > '/usr/lib64/python2.7', '/usr/lib64/python2.7/plat-linux2', > '/usr/lib64/python2.7/lib-tk', '/usr/lib64/python2.7/lib-old', > '/usr/lib64/python2.7/lib-dynload', '/usr/lib64/python2.7/site-packages', > '/usr/lib64/python2.7/site-packages/gtk-2.0', > '/usr/lib/python2.7/site-packages'] > > Looks like '/usr/share/vdsm' take precedence over > '/usr/lib64/python2.7/site-packages'. > > Can someone suggests a way to fix this issue? > > Note: '/sbin/gluster-eventsapi' works perfectly while running directly from > CLI. > > Related vdsm patch: > https://gerrit.ovirt.org/#/c/67168/2/vdsm/gluster/events.py
If an import fails because /usr/share/vdsm/foo hides a package in /usr/lib/python2.7/site-packages/vdsm it means that you have a wrong import, you need to import anything like this: from vdsm.foo import bar So names in /usr/share/vdsm/* cannot hide names in vdsm package. Nir _______________________________________________ Devel mailing list Devel@ovirt.org http://lists.ovirt.org/mailman/listinfo/devel