Here is an update to this thread. I am almost there. I would really appreciate any help from anyone.
After adding hidden import and hook path, I manage to make pandas.io.sql work. Here is part of the spec file: *hiddenimports=['pandas.io.sql'],* * hookspath=['/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pandas-0.11.0-py2.7-macosx-10.6-intel.egg/pandas/io'] * However, when I tried to do the same thing with *pandas.rpy.common* and rpy2.robjects, pyinstaller fails to package these two modules. I looked into *pandas.rpy.common*, the first few imports are *from rpy2.robjects import r* and import rpy2.robjects. Therefore, I guess the rest of the errors are coming from *rpy2.robjects*. Next, I looked into the *rpy2.robjects*. If I do *print rpy2.robjects.__file__*, the output is * /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/rpy2-2.3.6-py2.7-macosx-10.6-intel.egg/rpy2/robjects/__init__.pyc * so I tried to add these into the spec file: *hiddenimports=['pandas.io.sql', 'rpy2.robjects.__init__'],* *hookspath=['/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pandas-0.11.0-py2.7-macosx-10.6-intel.egg/pandas/io', '** /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/rpy2-2.3.6-py2.7-macosx-10.6-intel.egg/rpy2/robjects' **]* It still fails to package. Does anyone know the possible reason? I think I am really close to the end. Appreciate for any help and comments! On Friday, June 28, 2013 5:58:20 PM UTC-4, Boxuan Cui wrote: > > Thanks for the tip. This is what I got back from Python: > > *>>> import pandas.rpy.common as com* > *>>> import pandas.io.sql as psql* > *>>> import rpy2.robjects as robjects* > *>>> print com.__file__, '\n', psql.__file__, '\n', robjects.__file__* > * > /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pandas-0.11.0-py2.7-macosx-10.6-intel.egg/pandas/rpy/common.pyc > > * > * > /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pandas-0.11.0-py2.7-macosx-10.6-intel.egg/pandas/io/sql.pyc > > * > * > /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/rpy2-2.3.6-py2.7-macosx-10.6-intel.egg/rpy2/robjects/__init__.pyc > * > > > So I modified my spec file as this: > > *# -*- mode: python -*-* > *a = Analysis(['/Users/boxuancui/Documents/AA/Scripts/task.py'],* > * pathex=['/Users/boxuancui/Documents/AA/Final_app',* > * > > '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages', > * > *# > '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pandas-0.11.0-py2.7-macosx-10.6-intel.egg/pandas/rpy', > * > *# > '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pandas-0.11.0-py2.7-macosx-10.6-intel.egg/pandas/io', > * > *# > '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/rpy2-2.3.6-py2.7-macosx-10.6-intel.egg/rpy2/robjects'], > * > * hiddenimports=[],* > * hookspath=None,* > * runtime_hooks=None)* > > *pyz = PYZ(a.pure)* > * > * > *exe = EXE(pyz,* > * a.scripts,* > * exclude_binaries=True,* > * name='MyApp',* > * debug=False,* > * strip=None,* > * upx=True,* > * console=False , icon='/Users/boxuancui/Documents/AA/Mac.icns')* > * > * > *coll = COLLECT(exe,* > * a.binaries,* > * a.zipfiles,* > * a.datas,* > * strip=None,* > * upx=True,* > * name='**MyApp**')* > * > * > *app = BUNDLE(coll,* > * name='**MyApp**.app',* > * icon='/Users/boxuancui/Documents/AA/Mac.icns',* > * version=1.0)* > > > You noticed the commented code in *pathex*. I tried to build with and > without them. The app still crashes. Again, I am pretty sure these 3 > imports are creating problems, because the app could be opened without > these 3 imports. > > > > On Friday, June 28, 2013 12:22:43 AM UTC-4, Steve Barnes wrote: >> >> On 27/06/13 22:33, Boxuan Cui wrote: >> >> I deleted my previous post. The app won't crash, but it did not work as >> intended. >> >> I took a closer look and found that modules like *pandas.io.sql*, * >> rpy2.objects*, *pandas.rpy.common* do not exist at all. As a result, >> PyInstaller could not find them. However, if I do *import pandas.io.sql >> as psql*, *import rpy2.objects as robjects* and *import >> pandas.rpy.common as com*, it works. Why is this so? >> >> >> >> Don't forget that there may be a module/package pandas.io that contains >> an object called sql or even one called pandas that contains an object io >> that has a member called sql and just to add to the confusion there can be >> some renaming/aliasing so for example the pandas.io package could from >> pandas.os.whatever.sqlstuff import stuff as sql, etc. This sort of thing >> is especailly common when a package author has to deal with platform >> specific items. I have some in some of my code and pyinstaller & py2exe >> both have trouble unless I explicitly tell them to include the "real" >> package(s) or in cases where I am having to programmatically generate >> imports I can twist their arm by having somewhere in my code imports of all >> the possible results behind an if False: clause. >> >> You should be able to get a clue by adding to your code, after the >> imports, above: >> print psql.__file__ >> print robjects.__file__ >> etc. >> >> <snip> >> >> Gadget/Steve >> > -- You received this message because you are subscribed to the Google Groups "PyInstaller" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/pyinstaller. For more options, visit https://groups.google.com/groups/opt_out.
