Hello to all,

I would like to ask you what would be the best way to have a py2exe application able to import dynamically other python files.
Basically I want to deliver an application which has most of the code compiled, but a little part customizable by the users, by importing functions from py files.

For example:

import sys

def run_app(plugin_name):
    # import dynamically the py script
    exec 'import '+plugin_name+' as plugin'
    plugin.exec_main()

if __name__ == '__main__':
    run_app(sys.argv[1])


I get an error on the compiled version:

C:\Python25\Lib\site-packages\biokit\tmp\dynamic_import\dist>test.exe tmp_plugin
Traceback (most recent call last):
  File "test.py", line 9, in <module>
  File "test.py", line 5, in run_app
  File "<string>", line 1, in <module>
ImportError: No module named tmp_plugin

C:\Python25\Lib\site-packages\biokit\tmp\dynamic_import\dist>

It doesnt works ! Help :)


Hotmail: Free, trusted and rich email service. Get it now.