2012-10-03 84 views
1

我使用Python 2.7,寶途2.6,py2exe創建一個Windows可執行文件,與亞馬遜的Dynamodb交互。應用程序使用py2exe進行編譯,但每當與任何AWS交互時都會無限期地掛起。寶途與py2exe

這裏是我的py2exe

from distutils.core import setup 
import py2exe 
import sys 

setup(windows=[{"script" : "smart_gui.py"}], 
options={"py2exe" : { 
"includes" : ["sip", "PyQt4", "simplejson", "email","lxml","http", "urllib", 
"email"], 
"packages":["gzip", "email"], 
"excludes":["Carbon","_scproxy", "Carbon.Files"]}}) 

setup.py而此行導致程序無限期的手。

table = self.dynamo.get_table(self.conf['users_table']) 

下面是py2exe的培訓相關輸出

The following modules appear to be missing 
['Crypto.PublicKey._fastmath', 'builtins', 'cchardet', 'certifi', 'email.Charset', 
'email.Encoders', 'email.Errors', 'email.Generator', 'email.Header', 
'email.Iterators', 'email.MIMEAudio', 'email.MIMEBase', 'email.MIMEImage', 
'email.MIMEMessage', 'email.MIMEMultipart', 'email.MIMEText', 'email.Message', 
'email.Parser', 'email.Utils', 'email.base64MIME', 'email.quopriMIME', 'http.client', 
'http.cookiejar', 'http.cookies', 'kerberos', 'oauthlib.common', 'oauthlib.oauth1', 
'oauthlib.oauth1.rfc5849', 'packages.ssl_match_hostname.CertificateError', 
'packages.ssl_match_hostname.match_hostname', 'queue', 'simplejson._speedups', 
'test.test_support', 'urllib.parse', 'urllib.request'] 

Make sure you have the license if you distribute any of them, and 
make sure you don't distribute files belonging to the operating system. 

OLEAUT32.dll - C:\Windows\system32\OLEAUT32.dll 
USER32.dll - C:\Windows\system32\USER32.dll 
MSVCP90.dll - C:\Users\karl\Desktop\Smart_Select\MSVCP90.dll 
SHELL32.dll - C:\Windows\system32\SHELL32.dll 
KERNEL32.dll - C:\Windows\system32\KERNEL32.dll 
WINMM.dll - C:\Windows\system32\WINMM.dll 
COMDLG32.dll - C:\Windows\system32\COMDLG32.dll 
ADVAPI32.dll - C:\Windows\system32\ADVAPI32.dll 
NETAPI32.dll - C:\Windows\system32\NETAPI32.dll 
WS2_32.dll - C:\Windows\system32\WS2_32.dll 
WINSPOOL.DRV - C:\Windows\system32\WINSPOOL.DRV 
GDI32.dll - C:\Windows\system32\GDI32.dll 
IMM32.dll - C:\Windows\system32\IMM32.dll 
VERSION.dll - C:\Windows\system32\VERSION.dll 
ole32.dll - C:\Windows\system32\ole32.dll 
ntdll.dll - C:\Windows\system32\ntdll.dll 

我怎樣才能博託與py2exe工作?

回答

1

我花了大部分時間在此 - py2app將所有依賴關係包裝到site-packages.zip中,並且boto直接從zip存檔中讀取它的cacerts.txt(將它視爲一個目錄,沒有工作)。

我不清楚什麼(如果有的話)運行時解壓縮魔術py2app所做的,但最簡單的解決方案是製作我自己的cacerts.txt副本,將其作爲數據文件包含在py2app setup.py中:

DATA_FILES = [                                
#Add the cert                               
('backup_cacert', ['cacerts.txt'])                          
]    

然後在我的主要功能做這樣的事情:

import boto.connection                              
try:                                   
    open(boto.connection.DEFAULT_CA_CERTS_FILE)                        
except IOError as e:                                                                            
    boto.connection.DEFAULT_CA_CERTS_FILE = os.path.join(os.path.dirname(__file__), 'backup_cacert', 'cacerts.txt')                          
try:                                   
    open(boto.connection.DEFAULT_CA_CERTS_FILE)                        
except IOError as e:                               
    raise e