Hi Hartmut, This issue bother me for almost 2 weeks. i try the release version with --onefile or --onedir, it's not work. and i also try the development version with --onefile or --onedir, still no work. I am just wondering about how should i use find_module() when application run. is there something different between the executable which Pyinstaller produce and the normal execution method which running application directly using "python myapp" ? The following is all the information you need to locate the problem:
my own app has the directory structure like the following: application.py (the main entry) server.py app (a directory) |__common | |____commonservice.py |__helpers | |____...(many .py files and some sub-directory) |__controllers | |____request_login.py | |____redirect.py | |____...(many .py files and some sub-directory) |__.... 1. release version [problem description] can not import the modules in the "app/controllers" directory of my own app, both --onefile and --onedir got the same problem. The modules in the controllers is import by load_source() in the source code application.py when the app is running but if pyinstaller can't support this, import all of it during the building period of exectuable is another good idea but i don't know how to do it using pyinstaller except for the find_module problem, the executable file(--onefile mode) can run successfully ! [python version] 2.7.2 http://www.python.org/download/releases/2.7.2/ [pyinstaller version] 1.5.1 http://www.pyinstaller.org/ [platform version] SuSE Linux 10 SP2 x86_64(2.6.16.60-0.21-smp) [sample code] g = globals() modules = [] for strPath, lstDirs, lstFiles in os.walk(controllers_dir): if lstFiles == []: continue modules.extend([(f[:-3], os.path.join(strPath, f)) for f in lstFiles if f.endswith('.py')]) for (name, file) in modules: if name not in g: import_module(name, file) def import_module(name, file): m = load_source(name, file) g[name] = m [hook import] i tried make some hook file in the hooks directory in pyinstaller directory which filename like hook-app.controllers.py, hook-app.controllers.redirect.py and etc. the hook file content like hiddenimports = ['app.controllers.redirect'] whether i choose --onefile or --onedir, the outPYZ1.pyz does not include any of my modules in the app/controllers directory ? O outPYZ1.pyz Name: (ispkg, pos, len) {'BaseHTTPServer': (False, 862035, 8577), 'ConfigParser': (False, 592334, 9029), 'Cookie': (False, 1248832, 8924), ...... 'app': (True, 2203686, 106), 'app.common': (True, 298627, 113), 'app.common.bzCompress': (False, 169204, 692), 'app.common.commonservice': (False, 911797, 6360), 2.development version [problem description] i try development version , supprisingly, by adding some config item in .spec app, both --onefile and --onedir can import the modules in "app/controllers"! hiddenimports = ['app.controllers.redirect', 'app.controllers.request_login'] make the import work! but if i call find_module in main entry , it still not found the module which has been import succesfully in outPYZ1.pyz but the most worst thing is when i run the exectuable produced by development version, it throw some exception which is OK in release version . Traceback (most recent call last): File "<string>", line 181, in <module> File "<string>", line 99, in config_session File "/opt/buildengr/build/pyi.linux2/application/out01-PYZ.pyz/web.db", line 1142, in database File "/opt/buildengr/build/pyi.linux2/application/out01-PYZ.pyz/web.db", line 1011, in __init__ File "/opt/buildengr/build/pyi.linux2/application/out01-PYZ.pyz/web.db", line 1007, in import_driver ImportError: Unable to import sqlite3 or pysqlite2.dbapi2 or sqlite [python version] 2.7.2 http://www.python.org/download/releases/2.7.2/ [pyinstaller version] 1.5.1 http://www.pyinstaller.org/ [platform version] SuSE Linux 10 SP2 x86_64(2.6.16.60-0.21-smp) so the issue is so weird now, if i used release version, running executable is OK but can not import some modules and find_module; if i used development version, running executable throws exception but can import modules, still can't fine_module. your help will be fully appreciate , if you need any other thing pls let me know, thanks in advance. :) -- You received this message because you are subscribed to the Google Groups "PyInstaller" group. To view this discussion on the web visit https://groups.google.com/d/msg/pyinstaller/-/MhkfLMuyq7gJ. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/pyinstaller?hl=en.
