Running framework within .egg error

18 views
Skip to first unread message

Darren Govoni

unread,
May 17, 2016, 9:41:09 AM5/17/16
to ipopo-dev
Hi,
  I have created a .egg with my framework and all other files in it. It has a __main__.py
If I unzip the egg and run the __main__.py manually with PYTHONPATH=. it all works fine.

But running the .egg produces

$ python example_framework-1.0-py2.7.egg
Traceback (most recent call last):
  File "/usr/lib/python2.7/runpy.py", line 162, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "example_framework-1.0-py2.7.egg/__main__.py", line 18, in <module>
  File "example_framework-1.0-py2.7.egg/__main__.py", line 15, in main
....
....
  File "/home/darren/seekr/local/lib/python2.7/site-packages/pelix/framework.py", line 1364, in install_bundle
    return self.__framework.install_bundle(name, path)
  File "/home/darren/seekr/local/lib/python2.7/site-packages/pelix/framework.py", line 735, in install_bundle
    module = importlib.import_module(name)
  File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
IOError: zipimport: can not open file example_framework-1.0-py2.7.egg

Thomas Calmant

unread,
May 17, 2016, 12:59:38 PM5/17/16
to ipop...@googlegroups.com
Hi,

Could you print the value of sys.path in the __main__.py file, to see where the modules should be loaded from.
Also, do you have a sample egg file ?

Cheers,
Thomas


--
Vous recevez ce message, car vous êtes abonné au groupe Google Groupes "ipopo-dev".
Pour vous désabonner de ce groupe et ne plus recevoir d'e-mails le concernant, envoyez un e-mail à l'adresse ipopo-dev+...@googlegroups.com.
Pour obtenir davantage d'options, consultez la page https://groups.google.com/d/optout.

Darren Govoni

unread,
May 18, 2016, 8:07:17 AM5/18/16
to ipopo-dev
Hello,
   My egg is last in sys,path

....
'/usr/lib/python2.7/plat-x86_64-linux-gnu', '/usr/lib/python2.7/lib-tk', '/home/darren/seekr/local/lib/python2.7/site-packages', '/home/darren/git/seekr/apps/drs/dockers/framework/dist/example_framework-1.0-py2.7.egg']

I can email you the egg. Maybe it is finding a module but the module itself is not loading and the only error ipopo will throw is a bundle error or something.

Darren Govoni

unread,
May 18, 2016, 8:09:20 AM5/18/16
to ipopo-dev
I forgot I added the egg to the sys path to try. In __main__.py

sys.path.append(os.path.abspath('example_framework-1.0-py2.7.egg'))

But that didn't help.

Darren Govoni

unread,
May 18, 2016, 8:12:01 AM5/18/16
to ipopo-dev
I also tried path prepend.

['example_framework-1.0-py2.7.egg', '/home/darren/seekr/local/lib/python2.7/site-packages/importlib-1.0.3-py2.7.egg', '/home/darren/seekr/local/lib/python2.7/site-packages/networkx-1.11-py2.7.egg', '/home/darren/seekr/local/lib/python2.7/site-packages/elasticsearch-2.3.0-py2.7.egg', '/home/darren/seekr/local/lib/python2.7/site-packages/uWSGI-2.0.12-py2.7.egg', '/home/darren/seekr/local/lib/python2.7/site-packages/marisa_trie-0.7.2-py2.7-linux-x86_64.egg', '/home/darren/seekr/local/lib/python2.7/site-packages/BeautifulSoup-3.2.1-py2.7.egg', '/home/darren/seekr/local/lib/python2.7/site-packages/isodate-0.5.4-py2.7.egg', '/home/darren/seekr/local/lib/python2.7/site-p 
....
...

Darren Govoni

unread,
May 18, 2016, 8:15:16 AM5/18/16
to ipopo-dev
Ok, if I give absolute path on command line to python it works.

Thomas Calmant

unread,
May 18, 2016, 9:23:41 AM5/18/16
to ipop...@googlegroups.com
Just to be sure: it works when you manually prepend the full path to the egg file to sys.path, right ?
Or when you run the python command from the shell, giving the full path to the egg ?

This might be a problem of working directory/relative path, so it might be necessary for Pelix/iPOPO to normalize sys.path when starting.
Also, that error shows that the import stack trace isn't sufficient as the name of the bundle isn't show.

I can email you the egg. Maybe it is finding a module but the module itself is not loading and the only error ipopo will throw is a bundle error or something.

Thanks, that will allow me to have the exact same test artifact.

Cheers,
Thomas

Thomas Calmant

unread,
May 19, 2016, 4:43:33 AM5/19/16
to ipop...@googlegroups.com
Hi,

I've only had access to Python 3.5, and the .egg distribution seems to work well.
I tried with:
- The .egg ran from the system Python, with Pelix installed
- The .egg ran from a virtual environment without Pelix installed

Both versions work, and in both cases the relative path to the .egg file is the first entry in sys.path (in fact, the path given to Python).

Do you change the working directory in your code ?
If so, we should open an issue so that Pelix normalizes sys.path when starting.

Cheers,
Thomas

Thomas Calmant

unread,
May 25, 2016, 3:56:09 PM5/25/16
to ipopo-dev
Hi,

I've created an issue on GitHub [1] to try to avoid this kind of problem.

[1] https://github.com/tcalmant/ipopo/issues/61

Cheers,
Thomas

Thomas Calmant

unread,
Jun 6, 2016, 9:50:09 AM6/6/16
to ipopo-dev
Hi,

Could you test the latest version of iPOPO from the Git repository ?

I added a pelix.framework.normalize_path() method which ensures that all paths used in module imports are absolute.
It is called by create_framework() but can also be called manually early in the __main__ module, to ensure a valid path when the application is loaded.

Cheers,
Thomas
Reply all
Reply to author
Forward
0 new messages