轉載於:http://www.crifan.com/use_pyinstaller_to_package_python_to_single_executable_exe/
之前就想要把自己的BlogsToWordpress打開成exe了。一直沒去弄。
又看到有人提到python打開成exe的問題。
所以打算現在就去試試。
注:此處之所有選用BlogsToWordpress,是因爲此python腳本夠複雜,依賴的模塊夠多。
如果這個都搞定了,那麼其他單個的python文件,和小python項目的打包,就更不成問題了。
1.先去找找,目前主流有哪幾種方法。
找到幾個名字
cx_Freeze
PyInstaller
py2exe
2.關於py2exe和PyInstaller的兩者官網:
http://www.py2exe.org/index.cgi/FAQ
和
比較了一下,發現貌似後者更好用。
因爲貌似py2exe還需要另外的其他庫文件啊啥的,太瑣碎。
而PyInstaller:
所以先去試試PyInstaller。
3.從主頁
中下載對應的zip包:
https://github.com/downloads/pyinstaller/pyinstaller/pyinstaller-2.0.zip
得到3M+的pyinstaller-2.0.zip,解壓,打開cmd,進入對應目錄,去安裝,結果說不支持:
1
2
3
|
D:\tmp\dev_tools\python\to_exe\PyInstaller\pyinstaller-2.0>setup.py
install
setup.py is not yet supposed to work. Please Use PyInstaller without installation.
|
所以算了,還是參考官網文檔,一點點折騰吧。
4.參考在線文檔:
http://www.pyinstaller.org/export/v2.0/project/doc/Manual.html?format=raw
結果說需要PyWin32,所以得先去裝這個。
5.後來才發現,原來之前已經安裝過了:
【已解決】Python中出錯:ImportError: No module named win32com.client
但是要注意的是,import不是pywin32,而是win32com:
1
2
3
4
5
6
7
8
|
Python 2.7.3 (default, Apr 10 2012, 23:24:47) [MSC
v
.1500 64 bit (AMD64)] on win32
Type
"help"
,
"copyright"
,
"credits"
or
"license"
for
more
information.
>>>
import
pywin32
Traceback (most recent call last):
File
"<stdin>"
, line 1,
in
<module>
ImportError: No module named pywin32
>>>
import
win32com
>>>
|
6.繼續參考:
發現,解壓後,就算是安裝好了。
7.在一個文件夾中,準備好自己的Python程序:
D:\tmp\tmp_dev_root\python\tutorial_summary\make_exe\BlogsToWordpress
以備後用。
8.去到pyinstaller.py所在目錄,去運行:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
D:\tmp\tmp_dev_root\python\tutorial_summary\make_exe\pyinstaller-2.0>pyinstaller.py ..\BlogsToWordpress\BlogsToWordpress.py
232 INFO: wrote D:\tmp\tmp_dev_root\python\tutorial_summary\make_exe\pyinstaller-2.0\BlogsToWordpress\BlogsToWordpress.spec
250 INFO: Testing
for
ability to
set
icons, version resources...
269 INFO: ... resource update available
272 INFO: UPX is not available.
1437 INFO: checking Analysis
1437 INFO: building Analysis because out00-Analysis.toc non existent
1437 INFO: running Analysis out00-Analysis.toc
1439 INFO: Adding Microsoft.VC90.CRT to dependent assemblies of final executable
3074 INFO: Searching
for
assembly amd64_Microsoft.VC90.CRT_1fc8b3b9a1e18e3b_9.0.21022.8_none ...
3075 INFO: Found manifest C:\Windows\WinSxS\Manifests\amd64_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.21022.8_none_750b37ff97f4f68b.manifest
3081 INFO: Searching
for
file
msvcr90.dll
3081 INFO: Found
file
C:\Windows\WinSxS\amd64_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.21022.8_none_750b37ff97f4f68b\msvcr90.dll
3081 INFO: Searching
for
file
msvcp90.dll
3082 INFO: Found
file
C:\Windows\WinSxS\amd64_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.21022.8_none_750b37ff97f4f68b\msvcp90.dll
3082 INFO: Searching
for
file
msvcm90.dll
3082 INFO: Found
file
C:\Windows\WinSxS\amd64_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.21022.8_none_750b37ff97f4f68b\msvcm90.dll
3292 INFO: Analyzing D:\tmp\tmp_dev_root\python\tutorial_summary\make_exe\pyinstaller-2.0\support\_pyi_bootstrap.py
4048 INFO: Analyzing D:\tmp\tmp_dev_root\python\tutorial_summary\make_exe\pyinstaller-2.0\PyInstaller\loader\archive.py
4101 INFO: Analyzing D:\tmp\tmp_dev_root\python\tutorial_summary\make_exe\pyinstaller-2.0\PyInstaller\loader\carchive.py
4159 INFO: Analyzing D:\tmp\tmp_dev_root\python\tutorial_summary\make_exe\pyinstaller-2.0\PyInstaller\loader\iu.py
4176 INFO: Analyzing ..\BlogsToWordpress\BlogsToWordpress.py
4880 INFO: Hidden
import
'encodings'
has been found otherwise
4881 INFO: Looking
for
run-
time
hooks
4881 INFO: Analyzing rthook D:\tmp\tmp_dev_root\python\tutorial_summary\make_exe\pyinstaller-2.0\support
/rthooks/pyi_rth_encodings
.py
5523 INFO: Warnings written to D:\tmp\tmp_dev_root\python\tutorial_summary\make_exe\pyinstaller-2.0\BlogsToWordpress\build\pyi.win32\BlogsToWordpress\warnBlogsToWordpress.txt
5528 INFO: checking PYZ
5529 INFO: rebuilding out00-PYZ.toc because out00-PYZ.pyz is missing
5529 INFO: building PYZ out00-PYZ.toc
6225 INFO: checking PKG
6226 INFO: rebuilding out00-PKG.toc because out00-PKG.pkg is missing
6226 INFO: building PKG out00-PKG.pkg
6246 INFO: checking EXE
6246 INFO: rebuilding out00-EXE.toc because BlogsToWordpress.exe missing
6248 INFO: building EXE from out00-EXE.toc
6256 INFO: Appending archive to EXE D:\tmp\tmp_dev_root\python\tutorial_summary\make_exe\pyinstaller-2.0\BlogsToWordpress\build\pyi.win32\BlogsToWordpress\BlogsToWordpress.exe
6259 INFO: checking COLLECT
6259 INFO: building COLLECT out00-COLLECT.toc
D:\tmp\tmp_dev_root\python\tutorial_summary\make_exe\pyinstaller-2.0>
|
可以看到:
當前pyinstaller下面,的確生成了對應的BlogsToWordpress文件夾:
其下,也有對應的:
都已經生成了對應的exe了:
dist下面,有對應的,exe,pyd,dll等等:
汗,效率也忒高了,我還以爲,需要折騰半天才可以呢,囧。。。。
9.先去試試生成的exe,是否滿足我們的需求,是否可以獨立運行。
不過運行之前,還是去先研究一下對應的參數吧。
看到了:
很明顯,默認用的是-D,所以生成的是帶目錄的,現在重新去執行一次,使用-F生成單一的文件。
10.刪掉舊的。重新運行:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
D:\tmp\tmp_dev_root\python\tutorial_summary\make_exe\pyinstaller-2.0>pyinstaller.py -F ..\BlogsToWordpress\BlogsToWordpress.py
39 INFO: wrote D:\tmp\tmp_dev_root\python\tutorial_summary\make_exe\pyinstaller-2.0\BlogsToWordpress\BlogsToWordpress.spec
55 INFO: Testing
for
ability to
set
icons, version resources...
62 INFO: ... resource update available
63 INFO: UPX is not available.
848 INFO: checking Analysis
848 INFO: building Analysis because out00-Analysis.toc non existent
849 INFO: running Analysis out00-Analysis.toc
851 INFO: Adding Microsoft.VC90.CRT to dependent assemblies of final executable
905 INFO: Searching
for
assembly amd64_Microsoft.VC90.CRT_1fc8b3b9a1e18e3b_9.0.21022.8_none ...
907 INFO: Found manifest C:\Windows\WinSxS\Manifests\amd64_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.21022.8_none_750b37ff97f4f68b.manifest
908 INFO: Searching
for
file
msvcr90.dll
908 INFO: Found
file
C:\Windows\WinSxS\amd64_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.21022.8_none_750b37ff97f4f68b\msvcr90.dll
911 INFO: Searching
for
file
msvcp90.dll
911 INFO: Found
file
C:\Windows\WinSxS\amd64_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.21022.8_none_750b37ff97f4f68b\msvcp90.dll
912 INFO: Searching
for
file
msvcm90.dll
914 INFO: Found
file
C:\Windows\WinSxS\amd64_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.21022.8_none_750b37ff97f4f68b\msvcm90.dll
987 INFO: Analyzing D:\tmp\tmp_dev_root\python\tutorial_summary\make_exe\pyinstaller-2.0\support\_pyi_bootstrap.py
1639 INFO: Analyzing D:\tmp\tmp_dev_root\python\tutorial_summary\make_exe\pyinstaller-2.0\PyInstaller\loader\archive.py
1694 INFO: Analyzing D:\tmp\tmp_dev_root\python\tutorial_summary\make_exe\pyinstaller-2.0\PyInstaller\loader\carchive.py
1750 INFO: Analyzing D:\tmp\tmp_dev_root\python\tutorial_summary\make_exe\pyinstaller-2.0\PyInstaller\loader\iu.py
1766 INFO: Analyzing ..\BlogsToWordpress\BlogsToWordpress.py
2246 INFO: Hidden
import
'encodings'
has been found otherwise
2247 INFO: Looking
for
run-
time
hooks
2249 INFO: Analyzing rthook D:\tmp\tmp_dev_root\python\tutorial_summary\make_exe\pyinstaller-2.0\support
/rthooks/pyi_rth_encodings
.py
2608 INFO: Warnings written to D:\tmp\tmp_dev_root\python\tutorial_summary\make_exe\pyinstaller-2.0\BlogsToWordpress\build\pyi.win32\BlogsToWordpress\warnBlogsToWordpress.txt
2611 INFO: checking PYZ
2612 INFO: rebuilding out00-PYZ.toc because out00-PYZ.pyz is missing
2613 INFO: building PYZ out00-PYZ.toc
3290 INFO: checking PKG
3290 INFO: rebuilding out00-PKG.toc because out00-PKG.pkg is missing
3292 INFO: building PKG out00-PKG.pkg
4784 INFO: checking EXE
4784 INFO: rebuilding out00-EXE.toc because BlogsToWordpress.exe missing
4786 INFO: building EXE from out00-EXE.toc
4793 INFO: Appending archive to EXE D:\tmp\tmp_dev_root\python\tutorial_summary\make_exe\pyinstaller-2.0\BlogsToWordpress\dist\BlogsToWordpress.exe
|
去看看結果。
pyinstaller-2.0\BlogsToWordpress\build\pyi.win32\BlogsToWordpress
下面包含很多toc,pkg,pyz等文件:
dist下面,就生成了,所需要的單個exe文件:
但是,注意到了,生成文件中,包含一個警告的文件:
D:\tmp\tmp_dev_root\python\tutorial_summary\make_exe\pyinstaller-2.0\BlogsToWordpress\build\pyi.win32\BlogsToWordpress\warnBlogsToWordpress.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
W: no module named org (delayed import by xml.sax)
W: no module named _scproxy (conditional import by urllib)
W: no module named cl (delayed, conditional import by aifc)
W: no module named pwd (delayed, conditional import by posixpath)
W: no module named org (top-level import by pickle)
W: no module named Carbon (delayed import by plistlib)
W: no module named posix (delayed, conditional import by __main__)
W: no module named fcntl (conditional import by subprocess)
W: no module named BlogBaidu (top-level import by __main__)
W: no module named BlogCsdn (top-level import by __main__)
W: no module named BlogBlogbus (top-level import by __main__)
W: no module named java (conditional import by xml.sax._exceptions)
W: no module named BlogTianya (top-level import by __main__)
W: no module named readline (delayed import by pdb)
W: no module named AES (delayed, conditional import by archive)
W: no module named _emx_link (conditional import by os)
W: no module named pwd (delayed import by getpass)
W: no module named posix (delayed, conditional import by iu)
W: no module named EasyDialogs (conditional import by getpass)
W: no module named termios (top-level import by getpass)
W: no module named gestalt (delayed import by platform)
W: no module named org (top-level import by copy)
W: no module named fcntl (top-level import by tempfile)
W: no module named readline (delayed, conditional import by cmd)
W: no module named crifanLib (top-level import by __main__)
W: no module named SOCKS (top-level import by ftplib)
W: no module named java (delayed import by platform)
W: no module named cl (delayed import by aifc)
W: no module named BlogQQ (top-level import by __main__)
W: no module named xmlparse (top-level import by pyexpat)
W: no module named xmltok (top-level import by pyexpat)
W: no module named BlogDiandian (top-level import by __main__)
W: no module named BlogSohu (top-level import by __main__)
W: no module named BlogRenren (top-level import by __main__)
W: no module named AES (delayed, conditional import by __main__)
W: no module named posix (conditional import by os)
W: no module named BlogNetease (top-level import by __main__)
W: no module named MacOS (delayed import by platform)
W: no module named vms_lib (delayed, conditional import by platform)
W: no module named rourl2path (conditional import by urllib)
W: no module named _xmlplus (top-level import by xml)
W: no module named Crypt (delayed, conditional import by __main__)
W: no module named BlogSina (top-level import by __main__)
W: delayed exec statement detected at line 0 - bdb (D:\tmp\dev_install_root\Python27_x64\lib\bdb.pyc)
W: delayed eval hack detected at line 0 - bdb (D:\tmp\dev_install_root\Python27_x64\lib\bdb.pyc)
W: delayed eval hack detected at line 0 - bdb (D:\tmp\dev_install_root\Python27_x64\lib\bdb.pyc)
W: delayed __import__ hack detected at line 0 - optparse (D:\tmp\dev_install_root\Python27_x64\lib\optparse.pyc)
W: delayed conditional __import__ hack detected at line 0 - doctest (D:\tmp\dev_install_root\Python27_x64\lib\doctest.pyc)
W: delayed exec statement detected at line 0 - doctest (D:\tmp\dev_install_root\Python27_x64\lib\doctest.pyc)
W: delayed conditional __import__ hack detected at line 0 - doctest (D:\tmp\dev_install_root\Python27_x64\lib\doctest.pyc)
W: __all__ is built strangely at line 0 - tokenize (D:\tmp\dev_install_root\Python27_x64\lib\tokenize.pyc)
W: __all__ is built strangely at line 0 - tokenize (D:\tmp\dev_install_root\Python27_x64\lib\tokenize.pyc)
W: delayed __import__ hack detected at line 0 - pickle (D:\tmp\dev_install_root\Python27_x64\lib\pickle.pyc)
W: delayed __import__ hack detected at line 0 - pickle (D:\tmp\dev_install_root\Python27_x64\lib\pickle.pyc)
W: delayed __import__ hack detected at line 0 - encodings (D:\tmp\dev_install_root\Python27_x64\lib\encodings\__init__.pyc)
W: __all__ is built strangely at line 0 - dis (D:\tmp\dev_install_root\Python27_x64\lib\dis.pyc)
W: __all__ is built strangely at line 0 - hashlib (D:\tmp\dev_install_root\Python27_x64\lib\hashlib.pyc)
W: delayed conditional eval hack detected at line 0 - warnings (D:\tmp\dev_install_root\Python27_x64\lib\warnings.pyc)
W: delayed conditional __import__ hack detected at line 0 - warnings (D:\tmp\dev_install_root\Python27_x64\lib\warnings.pyc)
W: delayed __import__ hack detected at line 0 - email (D:\tmp\dev_install_root\Python27_x64\lib\email\__init__.pyc)
W: delayed exec statement detected at line 0 - pdb (D:\tmp\dev_install_root\Python27_x64\lib\pdb.pyc)
W: delayed conditional eval hack detected at line 0 - pdb (D:\tmp\dev_install_root\Python27_x64\lib\pdb.pyc)
W: delayed eval hack detected at line 0 - pdb (D:\tmp\dev_install_root\Python27_x64\lib\pdb.pyc)
W: delayed conditional eval hack detected at line 0 - pdb (D:\tmp\dev_install_root\Python27_x64\lib\pdb.pyc)
W: delayed eval hack detected at line 0 - pdb (D:\tmp\dev_install_root\Python27_x64\lib\pdb.pyc)
W: delayed conditional exec statement detected at line 0 - iu (D:\tmp\tmp_dev_root\python\tutorial_summary\make_exe\pyinstaller-2.0\PyInstaller\loader\iu.pyc)
W: delayed conditional exec statement detected at line 0 - iu (D:\tmp\tmp_dev_root\python\tutorial_summary\make_exe\pyinstaller-2.0\PyInstaller\loader\iu.pyc)
W: __all__ is built strangely at line 0 - collections (D:\tmp\dev_install_root\Python27_x64\lib\collections.pyc)
W: delayed exec statement detected at line 0 - collections (D:\tmp\dev_install_root\Python27_x64\lib\collections.pyc)
W: delayed conditional __import__ hack detected at line 0 - unittest.main (D:\tmp\dev_install_root\Python27_x64\lib\unittest\main.pyc)
W: delayed conditional __import__ hack detected at line 0 - unittest.loader (D:\tmp\dev_install_root\Python27_x64\lib\unittest\loader.pyc)
W: delayed conditional __import__ hack detected at line 0 - unittest.loader (D:\tmp\dev_install_root\Python27_x64\lib\unittest\loader.pyc)
W: delayed __import__ hack detected at line 0 - unittest.loader (D:\tmp\dev_install_root\Python27_x64\lib\unittest\loader.pyc)
W: __all__ is built strangely at line 0 - __future__ (D:\tmp\dev_install_root\Python27_x64\lib\__future__.pyc)
W: delayed __import__ hack detected at line 0 - xml.sax (D:\tmp\dev_install_root\Python27_x64\lib\xml\sax\__init__.pyc)
W: delayed eval hack detected at line 0 - gettext (D:\tmp\dev_install_root\Python27_x64\lib\gettext.pyc)
|
不知道是否影響程序。
11.去運行單個的exe,看看效果。
結果直接出錯:
1
2
3
4
5
6
|
D:\tmp\tmp_dev_root\python\tutorial_summary\make_exe\pyinstaller-2.0\BlogsToWordpress\dist>BlogsToWordpress.exe
Traceback (most recent call last):
File
"<string>"
, line 127,
in
<module>
File
"D:\tmp\tmp_dev_root\python\tutorial_summary\make_exe\pyinstaller-2.0\PyInstaller\loader\iu.py"
, line 409,
in
importHook
raise ImportError(
"No module named %s"
% fqname)
ImportError: No module named crifanLib
|
很明顯,還是無法自動導入很多的庫啊。
去想辦法,添加搜索路徑,讓其找到對應的庫。
12.好像是-p參數:
去試試:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
D:\tmp\tmp_dev_root\python\tutorial_summary\make_exe\pyinstaller-2.0>pyinstaller.py -F -p D:\tmp\tmp_dev_root\python\tutorial_summary\make_exe\BlogsToWordpress\libs;D:\tmp\tmp_dev_root\python\tutorial
_summary\make_exe\BlogsToWordpress\libs\crifan;D:\tmp\tmp_dev_root\python\tutorial_summary\make_exe\BlogsToWordpress\libs\crifan\blogModules;D:\tmp\tmp_dev_root\python\tutorial_summary\make_exe\BlogsT
oWordpress\libs\thirdparty;D:\tmp\tmp_dev_root\python\tutorial_summary\make_exe\BlogsToWordpress\libs\thirdparty\chardet; ..\BlogsToWordpress\BlogsToWordpress.py
18 INFO: wrote D:\tmp\tmp_dev_root\python\tutorial_summary\make_exe\pyinstaller-2.0\BlogsToWordpress\BlogsToWordpress.spec
33 INFO: Testing
for
ability to
set
icons, version resources...
36 INFO: ... resource update available
39 INFO: UPX is not available.
674 INFO: checking Analysis
677 INFO: building because pathex changed
679 INFO: running Analysis out00-Analysis.toc
680 INFO: Adding Microsoft.VC90.CRT to dependent assemblies of final executable
733 INFO: Searching
for
assembly amd64_Microsoft.VC90.CRT_1fc8b3b9a1e18e3b_9.0.21022.8_none ...
735 INFO: Found manifest C:\Windows\WinSxS\Manifests\amd64_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.21022.8_none_750b37ff97f4f68b.manifest
736 INFO: Searching
for
file
msvcr90.dll
736 INFO: Found
file
C:\Windows\WinSxS\amd64_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.21022.8_none_750b37ff97f4f68b\msvcr90.dll
738 INFO: Searching
for
file
msvcp90.dll
739 INFO: Found
file
C:\Windows\WinSxS\amd64_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.21022.8_none_750b37ff97f4f68b\msvcp90.dll
740 INFO: Searching
for
file
msvcm90.dll
743 INFO: Found
file
C:\Windows\WinSxS\amd64_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.21022.8_none_750b37ff97f4f68b\msvcm90.dll
812 INFO: Analyzing D:\tmp\tmp_dev_root\python\tutorial_summary\make_exe\pyinstaller-2.0\support\_pyi_bootstrap.py
1512 INFO: Analyzing D:\tmp\tmp_dev_root\python\tutorial_summary\make_exe\pyinstaller-2.0\PyInstaller\loader\archive.py
1578 INFO: Analyzing D:\tmp\tmp_dev_root\python\tutorial_summary\make_exe\pyinstaller-2.0\PyInstaller\loader\carchive.py
1648 INFO: Analyzing D:\tmp\tmp_dev_root\python\tutorial_summary\make_exe\pyinstaller-2.0\PyInstaller\loader\iu.py
1667 INFO: Analyzing ..\BlogsToWordpress\BlogsToWordpress.py
3016 INFO: Hidden
import
'encodings'
has been found otherwise
3016 INFO: Looking
for
run-
time
hooks
3018 INFO: Analyzing rthook D:\tmp\tmp_dev_root\python\tutorial_summary\make_exe\pyinstaller-2.0\support
/rthooks/pyi_rth_encodings
.py
3670 INFO: Warnings written to D:\tmp\tmp_dev_root\python\tutorial_summary\make_exe\pyinstaller-2.0\BlogsToWordpress\build\pyi.win32\BlogsToWordpress\warnBlogsToWordpress.txt
3674 INFO: checking PYZ
3679 INFO: building because toc changed
3679 INFO: building PYZ out00-PYZ.toc
5713 INFO: checking PKG
5716 INFO: building because D:\tmp\tmp_dev_root\python\tutorial_summary\make_exe\pyinstaller-2.0\BlogsToWordpress\build\pyi.win32\BlogsToWordpress\out00-PYZ.pyz changed
5717 INFO: building PKG out00-PKG.pkg
7163 INFO: checking EXE
7164 INFO: rebuilding out00-EXE.toc because pkg is
more
recent
7164 INFO: building EXE from out00-EXE.toc
7167 INFO: Appending archive to EXE D:\tmp\tmp_dev_root\python\tutorial_summary\make_exe\pyinstaller-2.0\BlogsToWordpress\dist\BlogsToWordpress.exe
D:\tmp\tmp_dev_root\python\tutorial_summary\make_exe\pyinstaller-2.0>
|
添加上路徑後,生成的exe,的確也大了一點,變成4505KB了:
另外,warnBlogsToWordpress.txt中,的確沒了crifanLib,但是還是有一些其他,可能要依賴的庫:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
W: no module named org (delayed
import
by xml.sax)
W: no module named PIL (delayed
import
by BlogRenren)
W: no module named _dummy_threading (
top
-level
import
by dummy_threading)
W: no module named cl (delayed, conditional
import
by aifc)
W: no module named
pwd
(delayed, conditional
import
by posixpath)
W: no module named org (
top
-level
import
by pickle)
W: no module named Carbon (delayed
import
by plistlib)
W: no module named PIL (delayed, conditional
import
by BlogNetease)
W: no module named posix (delayed, conditional
import
by __main__)
W: no module named iconv_codec (
top
-level
import
by BeautifulSoup)
W: no module named fcntl (conditional
import
by subprocess)
W: no module named MacOS (delayed
import
by platform)
W: no module named readline (delayed
import
by pdb)
W: no module named AES (delayed, conditional
import
by archive)
W: no module named _scproxy (conditional
import
by urllib)
W: no module named
pwd
(delayed
import
by getpass)
W: no module named posix (delayed, conditional
import
by iu)
W: no module named EasyDialogs (conditional
import
by getpass)
W: no module named termios (
top
-level
import
by getpass)
W: no module named gestalt (delayed
import
by platform)
W: no module named org (
top
-level
import
by copy)
W: no module named fcntl (
top
-level
import
by tempfile)
W: no module named cjkcodecs (
top
-level
import
by BeautifulSoup)
W: no module named readline (delayed, conditional
import
by cmd)
W: no module named java (delayed
import
by platform)
W: no module named cl (delayed
import
by aifc)
W: no module named xmlparse (
top
-level
import
by pyexpat)
W: no module named xmltok (
top
-level
import
by pyexpat)
W: no module named java (conditional
import
by xml.sax._exceptions)
W: no module named _emx_link (conditional
import
by os)
W: no module named posix (conditional
import
by os)
W: no module named rourl2path (conditional
import
by urllib)
W: no module named vms_lib (delayed, conditional
import
by platform)
W: no module named SOCKS (
top
-level
import
by ftplib)
W: no module named _xmlplus (
top
-level
import
by xml)
W: no module named Crypt (delayed, conditional
import
by __main__)
W: no module named AES (delayed, conditional
import
by __main__)
W: delayed
exec
statement detected at line 0 - bdb (D:\tmp\dev_install_root\Python27_x64\lib\bdb.pyc)
W: delayed
eval
hack detected at line 0 - bdb (D:\tmp\dev_install_root\Python27_x64\lib\bdb.pyc)
W: delayed
eval
hack detected at line 0 - bdb (D:\tmp\dev_install_root\Python27_x64\lib\bdb.pyc)
W: delayed __import__ hack detected at line 0 - optparse (D:\tmp\dev_install_root\Python27_x64\lib\optparse.pyc)
W: delayed conditional __import__ hack detected at line 0 - doctest (D:\tmp\dev_install_root\Python27_x64\lib\doctest.pyc)
W: delayed
exec
statement detected at line 0 - doctest (D:\tmp\dev_install_root\Python27_x64\lib\doctest.pyc)
W: delayed conditional __import__ hack detected at line 0 - doctest (D:\tmp\dev_install_root\Python27_x64\lib\doctest.pyc)
W: __all__ is built strangely at line 0 - tokenize (D:\tmp\dev_install_root\Python27_x64\lib\tokenize.pyc)
W: __all__ is built strangely at line 0 - tokenize (D:\tmp\dev_install_root\Python27_x64\lib\tokenize.pyc)
W: delayed __import__ hack detected at line 0 - pickle (D:\tmp\dev_install_root\Python27_x64\lib\pickle.pyc)
W: delayed __import__ hack detected at line 0 - pickle (D:\tmp\dev_install_root\Python27_x64\lib\pickle.pyc)
W: delayed __import__ hack detected at line 0 - encodings (D:\tmp\dev_install_root\Python27_x64\lib\encodings\__init__.pyc)
W: __all__ is built strangely at line 0 - dummy_threading (D:\tmp\dev_install_root\Python27_x64\lib\dummy_threading.pyc)
W: __all__ is built strangely at line 0 - dis (D:\tmp\dev_install_root\Python27_x64\lib\dis.pyc)
W: __all__ is built strangely at line 0 - hashlib (D:\tmp\dev_install_root\Python27_x64\lib\hashlib.pyc)
W: delayed conditional
eval
hack detected at line 0 - warnings (D:\tmp\dev_install_root\Python27_x64\lib\warnings.pyc)
W: delayed conditional __import__ hack detected at line 0 - warnings (D:\tmp\dev_install_root\Python27_x64\lib\warnings.pyc)
W: delayed __import__ hack detected at line 0 - email (D:\tmp\dev_install_root\Python27_x64\lib\email\__init__.pyc)
W: delayed
exec
statement detected at line 0 - pdb (D:\tmp\dev_install_root\Python27_x64\lib\pdb.pyc)
W: delayed conditional
eval
hack detected at line 0 - pdb (D:\tmp\dev_install_root\Python27_x64\lib\pdb.pyc)
W: delayed
eval
hack detected at line 0 - pdb (D:\tmp\dev_install_root\Python27_x64\lib\pdb.pyc)
W: delayed conditional
eval
hack detected at line 0 - pdb (D:\tmp\dev_install_root\Python27_x64\lib\pdb.pyc)
W: delayed
eval
hack detected at line 0 - pdb (D:\tmp\dev_install_root\Python27_x64\lib\pdb.pyc)
W: delayed conditional
exec
statement detected at line 0 - iu (D:\tmp\tmp_dev_root\python\tutorial_summary\make_exe\pyinstaller-2.0\PyInstaller\loader\iu.pyc)
W: delayed conditional
exec
statement detected at line 0 - iu (D:\tmp\tmp_dev_root\python\tutorial_summary\make_exe\pyinstaller-2.0\PyInstaller\loader\iu.pyc)
W: __all__ is built strangely at line 0 - collections (D:\tmp\dev_install_root\Python27_x64\lib\collections.pyc)
W: delayed
exec
statement detected at line 0 - collections (D:\tmp\dev_install_root\Python27_x64\lib\collections.pyc)
W: delayed conditional __import__ hack detected at line 0 - unittest.main (D:\tmp\dev_install_root\Python27_x64\lib\unittest\main.pyc)
W: delayed conditional __import__ hack detected at line 0 - unittest.loader (D:\tmp\dev_install_root\Python27_x64\lib\unittest\loader.pyc)
W: delayed conditional __import__ hack detected at line 0 - unittest.loader (D:\tmp\dev_install_root\Python27_x64\lib\unittest\loader.pyc)
W: delayed __import__ hack detected at line 0 - unittest.loader (D:\tmp\dev_install_root\Python27_x64\lib\unittest\loader.pyc)
W: __all__ is built strangely at line 0 - __future__ (D:\tmp\dev_install_root\Python27_x64\lib\__future__.pyc)
W: delayed __import__ hack detected at line 0 - xml.sax (D:\tmp\dev_install_root\Python27_x64\lib\xml\sax\__init__.pyc)
W: delayed
eval
hack detected at line 0 - gettext (D:\tmp\dev_install_root\Python27_x64\lib\gettext.pyc)
|
比如,其中的PIL等庫。
不過,關於PIL,我去看了看自己的
D:\tmp\dev_install_root\Python27_x64\Lib\site-packages
中的確沒有,應該是重裝python,導致了之前安裝好的PIL沒了。
所以,還是需要自己重新安裝一下PIL的。
12.關於安裝PIL的過程,詳見:
【記錄】下載和安裝Python的第三方圖像處理的庫:PIL(Python Imaging Library)
13.然後再去
D:\tmp\dev_install_root\Python27_x64\Lib\site-packages
確認一下,果然有了PIL了。
然後此處,刪掉舊的,重新執行一次:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
D:\tmp\tmp_dev_root\python\tutorial_summary\make_exe\pyinstaller-2.0>pyinstaller.py -F -p D:\tmp\tmp_dev_root\python\tutorial_summary\make_exe\BlogsToWordpress\libs;D:\tmp\tmp_dev_root\python\tutorial
_summary\make_exe\BlogsToWordpress\libs\crifan;D:\tmp\tmp_dev_root\python\tutorial_summary\make_exe\BlogsToWordpress\libs\crifan\blogModules;D:\tmp\tmp_dev_root\python\tutorial_summary\make_exe\BlogsT
oWordpress\libs\thirdparty;D:\tmp\tmp_dev_root\python\tutorial_summary\make_exe\BlogsToWordpress\libs\thirdparty\chardet; ..\BlogsToWordpress\BlogsToWordpress.py
18 INFO: wrote D:\tmp\tmp_dev_root\python\tutorial_summary\make_exe\pyinstaller-2.0\BlogsToWordpress\BlogsToWordpress.spec
33 INFO: Testing
for
ability to
set
icons, version resources...
37 INFO: ... resource update available
39 INFO: UPX is not available.
684 INFO: checking Analysis
684 INFO: building Analysis because out00-Analysis.toc non existent
684 INFO: running Analysis out00-Analysis.toc
685 INFO: Adding Microsoft.VC90.CRT to dependent assemblies of final executable
740 INFO: Searching
for
assembly amd64_Microsoft.VC90.CRT_1fc8b3b9a1e18e3b_9.0.21022.8_none ...
741 INFO: Found manifest C:\Windows\WinSxS\Manifests\amd64_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.21022.8_none_750b37ff97f4f68b.manifest
742 INFO: Searching
for
file
msvcr90.dll
743 INFO: Found
file
C:\Windows\WinSxS\amd64_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.21022.8_none_750b37ff97f4f68b\msvcr90.dll
744 INFO: Searching
for
file
msvcp90.dll
745 INFO: Found
file
C:\Windows\WinSxS\amd64_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.21022.8_none_750b37ff97f4f68b\msvcp90.dll
747 INFO: Searching
for
file
msvcm90.dll
750 INFO: Found
file
C:\Windows\WinSxS\amd64_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.21022.8_none_750b37ff97f4f68b\msvcm90.dll
821 INFO: Analyzing D:\tmp\tmp_dev_root\python\tutorial_summary\make_exe\pyinstaller-2.0\support\_pyi_bootstrap.py
1531 INFO: Analyzing D:\tmp\tmp_dev_root\python\tutorial_summary\make_exe\pyinstaller-2.0\PyInstaller\loader\archive.py
1600 INFO: Analyzing D:\tmp\tmp_dev_root\python\tutorial_summary\make_exe\pyinstaller-2.0\PyInstaller\loader\carchive.py
1672 INFO: Analyzing D:\tmp\tmp_dev_root\python\tutorial_summary\make_exe\pyinstaller-2.0\PyInstaller\loader\iu.py
1692 INFO: Analyzing ..\BlogsToWordpress\BlogsToWordpress.py
2903 INFO: Hidden
import
'encodings'
has been found otherwise
2904 INFO: Looking
for
run-
time
hooks
2905 INFO: Analyzing rthook D:\tmp\tmp_dev_root\python\tutorial_summary\make_exe\pyinstaller-2.0\support
/rthooks/pyi_rth_PIL_Image
.py
2917 INFO: Analyzing rthook D:\tmp\tmp_dev_root\python\tutorial_summary\make_exe\pyinstaller-2.0\support
/rthooks/pyi_rth_encodings
.py
3319 INFO: Warnings written to D:\tmp\tmp_dev_root\python\tutorial_summary\make_exe\pyinstaller-2.0\BlogsToWordpress\build\pyi.win32\BlogsToWordpress\warnBlogsToWordpress.txt
3325 INFO: checking PYZ
3326 INFO: rebuilding out00-PYZ.toc because out00-PYZ.pyz is missing
3326 INFO: building PYZ out00-PYZ.toc
5360 INFO: checking PKG
5360 INFO: rebuilding out00-PKG.toc because out00-PKG.pkg is missing
5361 INFO: building PKG out00-PKG.pkg
6839 INFO: checking EXE
6839 INFO: rebuilding out00-EXE.toc because BlogsToWordpress.exe missing
6840 INFO: building EXE from out00-EXE.toc
6842 INFO: Appending archive to EXE D:\tmp\tmp_dev_root\python\tutorial_summary\make_exe\pyinstaller-2.0\BlogsToWordpress\dist\BlogsToWordpress.exe
D:\tmp\tmp_dev_root\python\tutorial_summary\make_exe\pyinstaller-2.0>
|
雖然結果警告中,也還是有PIL:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
W: no module named org (delayed
import
by xml.sax)
W: no module named _dummy_threading (
top
-level
import
by dummy_threading)
W: no module named cl (delayed, conditional
import
by aifc)
W: no module named
pwd
(delayed, conditional
import
by posixpath)
W: no module named org (
top
-level
import
by pickle)
W: no module named Carbon (delayed
import
by plistlib)
W: no module named posix (delayed, conditional
import
|