2015-10-25 19 views
2

在Win10 x64上運行Python 3.5。已經嘗試py2exe,PyInstaller和cxfreeze。他們都運行並生成一個.exe。但所有這些.exes都不會在發生錯誤後立即關閉。他們都有警告日誌,其中包含大量無法正確導入的必需模塊列表。Python可執行文件 - 無法導入模塊

PyInstaller:

missing module named time.time - imported by time, http.cookies 
... 
missing module named urllib.proxy_bypass - imported by urllib, requests.compat 
... 

cxfreeze:

Missing modules: 

    ? Cookie imported from requests.compat 
    ? Image imported from openpyxl.drawing.image 
    ? OpenSSL.SSL imported from requests.packages.urllib3.contrib.pyopenssl 
    ? StringIO imported from requests.compat, requests.packages.urllib3.packages.six 
    ... 

PyInstaller也會引發扶養錯誤,例如 「API-MS-雙贏CRT-運行時l1-1-0.dll」 失蹤。我也安裝了Visual C++ 2005-2015,並安裝了Visual Studio Community 15。

+0

我有一些** py2exe **的使用經驗,你能告訴我你遇到了什麼錯誤嗎? – CrakC

+0

@CrakC我認爲py2exe,它不支持python 3.5,因爲它一直試圖打開一個3.4版本文件。另外,安裝時(不是通過pip),它要求我指向我的python 3.4目錄和qu當它沒有找到一個 – Prof

+0

另外,Win10是一個新的操作系統,兼容性問題在這種情況下非常明顯。從3.5移到3.4是否有問題? – CrakC

回答

0
PyInstaller 3.0 Python 3.5 on Win10 x64 with Visual Studio Community 15 
works for me. I run pyinstaller --onefile file_script.py 
    in windows path i have the folowing 
    C:\Python35; 
    C:\Python35\Scripts; 
    C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin; 
+0

立即我注意到我沒有將Python安裝到C根(我喜歡保持乾淨!),你認爲這可能會導致問題,腳本試圖找到相對於它們的位置的文件? – Prof

+0

@Prof,是的,它可能就是這樣。 – LetzerWille

+0

你知道改變安裝目錄的一種無痛的方式嗎?我假設卸載和重新安裝會失去我所有的自定義模塊? – Prof

0

原來,這是openpyxl的一個問題,它是一個被導入的模塊。

https://bitbucket.org/openpyxl/openpyxl/issues/498/moving-constants-to-a-configuration-file https://bitbucket.org/openpyxl/openpyxl/pull-requests/67/include-constantsjson-as-part-of-the/diff https://bitbucket.org/openpyxl/openpyxl/pull-requests/83/use-__about__py-instead-of-constantsjson/diff

下載資源庫的一個副本,使用在最後URL所做的更改,然後在安裝從openpyxl(使用`PIP安裝-e(openpyxldirectory)允許工作的.exe來生成