之前就想要把自己的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:
- 可以只是生成单独的可执行程序
- 且支持的版本也多:2.3到2.7都支持。以及x64也支持
- 也可以自定义图标
所以先去试试pyinstaller。
3.从主页
中下载对应的zip包:
https://github.com/downloads/pyinstaller/pyinstaller/pyinstaller-2.0.zip
得到3m+的pyinstaller-2.0.zip,解压,打开cmd,进入对应目录,去安装,结果说不支持:
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,是否满足我们的需求,是否可以独立运行。
不过运行之前,还是去先研究一下对应的参数吧。
看到了:
what to generate:
-f, --onefile
create a single file deployment
-d, --onedir
create a single directory deployment (default)
-o dir, --out=dir
create the spec file in directory. if not specified, and the current directory is installer's root directory, an output subdirectory will be created. otherwise the current directory is used.
-n name, --name=name
optional name to assign to the project (from which the spec file name is generated). if omitted, the basename of the (first) script is used.
很明显,默认用的是-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参数:
-p dir, --paths=dir
set base path for import (like using pythonpath). multiple directories are allowed, separating them with the path separator (‘;' under windows, ‘:' under linux), or using this option multiple times.
去试试:
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 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 _imaging_gif (top - level import by pil.gifimageplugin) 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 iccprofile (delayed, conditional import by pil.pngimageplugin) 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 __import__ hack detected at line 0 - pil.image (d:\tmp\dev_install_root\python27_x64\lib\site - packages\pil\image.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模块内部的一些小问题罢了,不理会。
生成的exe,的确又变大了,4748kb:
13.去运行现在的最新的blogstowordpress.exe,看看效果如何。
果然是可以,如期望的一样,去执行了:
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
|
d:\tmp\tmp_dev_root\python\tutorial_summary\make_exe\pyinstaller - 2.0 \blogstowordpress\dist>blogstowordpress.exe imported: crifanlib, v2. 4 imported: blognetease, v1. 4 imported: blogbaidu, v3. 4 imported: blogsina, v1. 5 imported: blogqq, v1. 8 imported: blogcsdn, v1. 1 imported: blogsohu, v1. 3 line 1600 : info current runtime info: line 1600 : info paramenters : [ 'd:\\tmp\\tmp_dev_root\\python\\tutorial_summary\\make_exe\\pyinstaller-2.0\\blogstowordpress\\dist\\blogstowordpress.exe' ] line 1600 : info python version : sys.version_info(major = 2 , minor = 7 , micro = 3 , releaselevel = 'final' , serial = 0 ) line 1600 : info platform.machine() = amd64 line 1600 : info platform.node() = pc - cli - 1 line 1600 : info platform.platform() = windows - 7 - 6.1 . 7601 - sp1 line 1600 : info platform.processor() = intel64 family 6 model 42 stepping 7 , genuineintel line 1600 : info platform.python_build() = ( 'default' , 'apr 10 2012 23:24:47' ) line 1600 : info platform.python_compiler() = msc v. 1500 64 bit (amd64) line 1600 : info platform.python_branch() = line 1600 : info platform.python_implementation() = cpython line 1600 : info platform.python_revision() = line 1600 : info platform.python_version() = 2.7 . 3 line 1600 : info platform.python_version_tuple() = ( '2' , '7' , '3' ) line 1600 : info platform.release() = 7 line 1600 : info platform.system() = windows line 1600 : info platform.version() = 6.1 . 7601 line 1600 : info platform.uname() = ( 'windows' , 'pc-cli-1' , '7' , '6.1.7601' , 'amd64' , 'intel64 family 6 model 42 stepping 7, genuineintel' ) line 1600 : info default encoding : ascii line 1600 : info current path : c:\users\cli\appdata\local\temp\_mei252922 line 1600 : info 版本信息:v16. 8 line 1600 : info 1. 如果脚本运行出错,请务必把上述( 1 )从脚本开始运行到上述所打印出来的系统信息( 2 )出错时候的相关信息( 3 )脚本所生成的blogstowordpress.log文件,通过复制粘贴、截图、附件等方式 line 1600 : info 发送至admin(at)crifan.com或跟帖(下面有地址)回复,否则如果没有足够的错误相关信息,我就是想帮你解决问题,也没法帮啊! line 1600 : info 2. 如对此脚本使用有任何疑问,请输入 - h参数以获得相应的参数说明。 line 1600 : info 3. 关于本程序详细的使用说明和更多相关信息,请参考: line 1600 : info blogstowordpress:将百度空间(新版和旧版),网易 163 ,新浪sina,qq空间,人人网,csdn,搜狐sohu,博客大巴blogbus,天涯博客,点点轻博客等博客搬家到wordpress line 1600 : info https: / / www.crifan.com / crifan_released_all / website / python / blogstowordpress / line 1600 : info - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - line 1600 : info your process type of post is : export post to wxr(wordpress extended rss). line 1575 : error must designate the entry url for the first blog item ! line 1575 : error unknown error ! traceback (most recent call last): file "<string>" , line 1931 , in <module> file "<string>" , line 1655 , in main systemexit: 2 d:\tmp\tmp_dev_root\python\tutorial_summary\make_exe\pyinstaller - 2.0 \blogstowordpress\dist> |
加上对应参数,再试试:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
d:\tmp\tmp_dev_root\python\tutorial_summary\make_exe\pyinstaller - 2.0 \blogstowordpress\dist>blogstowordpress.exe - s http: / / againinput4.blog. 163.com imported: crifanlib, v2. 4 imported: blognetease, v1. 4 imported: blogbaidu, v3. 4 imported: blogsina, v1. 5 imported: blogqq, v1. 8 imported: blogcsdn, v1. 1 imported: blogsohu, v1. 3 line 1600 : info current runtime info: line 1600 : info paramenters : [ 'd:\\tmp\\tmp_dev_root\\python\\tutorial_summary\\make_exe\\pyinstaller-2.0\\blogstowordpress\\dist\\blogstowordpress.exe' , '-s' , 'http: / / againinput4.blog. 163 .com'] line 1600 : info python version : sys.version_info(major = 2 , minor = 7 , micro = 3 , releaselevel = 'final' , serial = 0 ) line 1600 : info platform.machine() = amd64 line 1600 : info platform.node() = pc - cli - 1 line 1600 : info platform.platform() = windows - 7 - 6.1 . 7601 - sp1 line 1600 : info platform.processor() = intel64 family 6 model 42 stepping 7 , genuineintel line 1600 : info platform.python_build() = ( 'default' , 'apr 10 2012 23:24:47' ) line 1600 : info platform.python_compiler() = msc v. 1500 64 bit (amd64) ... |
的确就是可以正常执行了。
剩下的,就是要拿到别的windows平台上,多测试测试,是否都正常。
14.接着打算再去试试,添加icon图标的事情。
参考官网的参数解释:
-r file[,type[,name[,language]]], –resource=file[,type[,name[,language]]]
add/update resource of the given type, name and language from file to the final executable. file can be a data file or an exe/dll. for data files, atleast type and name need to be specified, language defaults to 0 or may be specified as wildcard * to update all resources of the given type and name. for exe/dll files, all resources from file will be added/updated to the final executable if type, name and language are omitted or specified as wildcard *.multiple resources are allowed, using this option multiple times.
去运行:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
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; - i ..\blogstowordpress\blogstowordpress.ico ..\blogstowordpress\blogstowordpre ss.py 18 info: wrote d:\tmp\tmp_dev_root\python\tutorial_summary\make_exe\pyinstaller - 2.0 \blogstowordpress\blogstowordpress.spec 34 info: testing for ability to set icons, version resources... 37 info: ... resource update available 40 info: upx is not available. 681 info: checking analysis 696 info: checking pyz 709 info: checking pkg 711 info: building because d:\tmp\tmp_dev_root\python\tutorial_summary\make_exe\pyinstaller - 2.0 \blogstowordpress\build\pyi.win32\blogstowordpress\blogstowordpress.exe.manifest changed 712 info: building pkg out00 - pkg.pkg 2190 info: checking exe 2192 info: building because icon changed 2192 info: building exe from out00 - exe.toc 2207 info: srcpath [( '..\\blogstowordpress\\blogstowordpress.ico' , none)] 2207 info: updating icons from [ '..\\blogstowordpress\\blogstowordpress.ico' ] to c:\users\cli\appdata\local\temp\tmpouutgx 2209 info: writing rt_group_icon 0 resource with 34 bytes 2211 info: writing rt_icon 1 resource with 1128 bytes 2213 info: writing rt_icon 2 resource with 4264 bytes 2222 info: appending archive to exe d:\tmp\tmp_dev_root\python\tutorial_summary\make_exe\pyinstaller - 2.0 \blogstowordpress\dist\blogstowordpress.exe |
可以看到,其自动会把icon添加到当前已有的exe中,然后可以看到对应的,带图标的exe的效果:
总结
pyinstaller,的确非常好用啊。感谢作者们。
简单总结其使用方法:
生成单一的exe文件:
pyinstaller.py -f ..\blogstowordpress\blogstowordpress.py
添加必要的搜索路径:
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\blogstowordpress\libs\thirdparty;d:\tmp\tmp_dev_root\python\tutorial_summary\make_exe\blogstowordpress\libs\thirdparty\chardet; ..\blogstowordpress\blogstowordpress.py
添加必要的搜索路径,且带图标:
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\blogstowordpress\libs\thirdparty;d:\tmp\tmp_dev_root\python\tutorial_summary\make_exe\blogstowordpress\libs\thirdparty\chardet; -i ..\blogstowordpress\blogstowordpress.ico ..\blogstowordpress\blogstowordpress.py
需要注意的是:
1.检查生成的
pyinstaller-2.0\xxx\build\pyi.win32\xxx\warnxxx.txt
(xxx是你的项目名)
中,是否缺少了必要的模块。
如果有缺少的,那么去如上所述,添加必要的搜素路径,使得pyinstaller在运行时,可以找到对应的模块并集成进来。
2.此处我这里没有upx,暂时没去折腾。
估计是用upx去压缩,压缩后所生成的exe文件的大小,会小得多。
原文链接:https://www.crifan.com/use_pyinstaller_to_package_python_to_single_executable_exe/