0

So I have made a small gui application using pygobject. Works fine and all when executed from the directory.

Tried to make a python package out of it but get this error everytime:

    In [2]: pygofortune.pygofortune.main()
---------------------------------------------------------------------------
Error                                     Traceback (most recent call last)
<ipython-input-2-1e2e05b4c484> in <module>()
----> 1 pygofortune.pygofortune.main()

/usr/lib/python3.5/site-packages/pygofortune-0.1-py3.5.egg/pygofortune/pygofortune.py in main()
     55 def main():
     56     builder = Gtk.Builder()
---> 57     builder.add_from_file("fortune.glade")
     58     builder.connect_signals(Handler())
     59     global win, buffer, about

Error: g-file-error-quark: Failed to open file 'fortune.glade': No such file or directory (4)

I had include the files in MANIFEST.in.

The files were present in the sitepackages folder of package too.

Any ideas what I may have done wrong

Vatsal
  • 462
  • 3
  • 9

1 Answers1

1

A filename without a path component will be looked for relative to the current working directory, not the directory where the Python script is installed.

I suggest using something like the pkg_resources feature of Setuptools to install your data files to a known location and retrieve their paths at runtime.

ptomato
  • 56,175
  • 13
  • 112
  • 165