用PyInstaller把Python代码打包成单个独立的exe可执行文件

时间:2021-05-22

之前就想要把自己的BlogsToWordpress打开成exe了。一直没去弄。

又看到有人提到python打开成exe的问题。

所以打算现在就去试试。

注:此处之所有选用BlogsToWordpress,是因为此python脚本够复杂,依赖的模块够多。

如果这个都搞定了,那么其他单个的python文件,和小python项目的打包,就更不成问题了。

1.先去找找,目前主流有哪几种方法。

找到几个名字

cx_Freeze

PyInstaller

py2exe

2.关于py2exe和PyInstaller的两者官网:

http://>>>

6.继续参考:

Installing PyInstaller

发现,解压后,就算是安装好了。

7.在一个文件夹中,准备好自己的Python程序:

D:\tmp\tmp_dev_root\python\tutorial_summary\make_exe\BlogsToWordpress

以备后用。

8.去到pyinstaller.py所在目录,去运行:

D:\tmp\tmp_dev_root\python\tutorial_summary\make_exe\pyinstaller-2.0>pyinstaller.py ..\BlogsToWordpress\BlogsToWordpress.py232 INFO: wrote D:\tmp\tmp_dev_root\python\tutorial_summary\make_exe\pyinstaller-2.0\BlogsToWordpress\BlogsToWordpress.spec250 INFO: Testing for ability to set icons, version resources...269 INFO: ... resource update available272 INFO: UPX is not available.1437 INFO: checking Analysis1437 INFO: building Analysis because out00-Analysis.toc non existent1437 INFO: running Analysis out00-Analysis.toc1439 INFO: Adding Microsoft.VC90.CRT to dependent assemblies of final executable3074 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.manifest3081 INFO: Searching for file msvcr90.dll3081 INFO: Found file C:\Windows\WinSxS\amd64_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.21022.8_none_750b37ff97f4f68b\msvcr90.dll3081 INFO: Searching for file msvcp90.dll3082 INFO: Found file C:\Windows\WinSxS\amd64_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.21022.8_none_750b37ff97f4f68b\msvcp90.dll3082 INFO: Searching for file msvcm90.dll3082 INFO: Found file C:\Windows\WinSxS\amd64_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.21022.8_none_750b37ff97f4f68b\msvcm90.dll3292 INFO: Analyzing D:\tmp\tmp_dev_root\python\tutorial_summary\make_exe\pyinstaller-2.0\support\_pyi_bootstrap.py4048 INFO: Analyzing D:\tmp\tmp_dev_root\python\tutorial_summary\make_exe\pyinstaller-2.0\PyInstaller\loader\archive.py4101 INFO: Analyzing D:\tmp\tmp_dev_root\python\tutorial_summary\make_exe\pyinstaller-2.0\PyInstaller\loader\carchive.py4159 INFO: Analyzing D:\tmp\tmp_dev_root\python\tutorial_summary\make_exe\pyinstaller-2.0\PyInstaller\loader\iu.py4176 INFO: Analyzing ..\BlogsToWordpress\BlogsToWordpress.py4880 INFO: Hidden import 'encodings' has been found otherwise4881 INFO: Looking for run-time hooks4881 INFO: Analyzing rthook D:\tmp\tmp_dev_root\python\tutorial_summary\make_exe\pyinstaller-2.0\support/rthooks/pyi_rth_encodings.py5523 INFO: Warnings written to D:\tmp\tmp_dev_root\python\tutorial_summary\make_exe\pyinstaller-2.0\BlogsToWordpress\build\pyi.win32\BlogsToWordpress\warnBlogsToWordpress.txt5528 INFO: checking PYZ5529 INFO: rebuilding out00-PYZ.toc because out00-PYZ.pyz is missing5529 INFO: building PYZ out00-PYZ.toc6225 INFO: checking PKG6226 INFO: rebuilding out00-PKG.toc because out00-PKG.pkg is missing6226 INFO: building PKG out00-PKG.pkg6246 INFO: checking EXE6246 INFO: rebuilding out00-EXE.toc because BlogsToWordpress.exe missing6248 INFO: building EXE from out00-EXE.toc6256 INFO: Appending archive to EXE D:\tmp\tmp_dev_root\python\tutorial_summary\make_exe\pyinstaller-2.0\BlogsToWordpress\build\pyi.win32\BlogsToWordpress\BlogsToWordpress.exe6259 INFO: checking COLLECT6259 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.删掉旧的。重新运行:

D:\tmp\tmp_dev_root\python\tutorial_summary\make_exe\pyinstaller-2.0>pyinstaller.py -F ..\BlogsToWordpress\BlogsToWordpress.py39 INFO: wrote D:\tmp\tmp_dev_root\python\tutorial_summary\make_exe\pyinstaller-2.0\BlogsToWordpress\BlogsToWordpress.spec55 INFO: Testing for ability to set icons, version resources...62 INFO: ... resource update available63 INFO: UPX is not available.848 INFO: checking Analysis848 INFO: building Analysis because out00-Analysis.toc non existent849 INFO: running Analysis out00-Analysis.toc851 INFO: Adding Microsoft.VC90.CRT to dependent assemblies of final executable905 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.manifest908 INFO: Searching for file msvcr90.dll908 INFO: Found file C:\Windows\WinSxS\amd64_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.21022.8_none_750b37ff97f4f68b\msvcr90.dll911 INFO: Searching for file msvcp90.dll911 INFO: Found file C:\Windows\WinSxS\amd64_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.21022.8_none_750b37ff97f4f68b\msvcp90.dll912 INFO: Searching for file msvcm90.dll914 INFO: Found file C:\Windows\WinSxS\amd64_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.21022.8_none_750b37ff97f4f68b\msvcm90.dll987 INFO: Analyzing D:\tmp\tmp_dev_root\python\tutorial_summary\make_exe\pyinstaller-2.0\support\_pyi_bootstrap.py1639 INFO: Analyzing D:\tmp\tmp_dev_root\python\tutorial_summary\make_exe\pyinstaller-2.0\PyInstaller\loader\archive.py1694 INFO: Analyzing D:\tmp\tmp_dev_root\python\tutorial_summary\make_exe\pyinstaller-2.0\PyInstaller\loader\carchive.py1750 INFO: Analyzing D:\tmp\tmp_dev_root\python\tutorial_summary\make_exe\pyinstaller-2.0\PyInstaller\loader\iu.py1766 INFO: Analyzing ..\BlogsToWordpress\BlogsToWordpress.py2246 INFO: Hidden import 'encodings' has been found otherwise2247 INFO: Looking for run-time hooks2249 INFO: Analyzing rthook D:\tmp\tmp_dev_root\python\tutorial_summary\make_exe\pyinstaller-2.0\support/rthooks/pyi_rth_encodings.py2608 INFO: Warnings written to D:\tmp\tmp_dev_root\python\tutorial_summary\make_exe\pyinstaller-2.0\BlogsToWordpress\build\pyi.win32\BlogsToWordpress\warnBlogsToWordpress.txt2611 INFO: checking PYZ2612 INFO: rebuilding out00-PYZ.toc because out00-PYZ.pyz is missing2613 INFO: building PYZ out00-PYZ.toc3290 INFO: checking PKG3290 INFO: rebuilding out00-PKG.toc because out00-PKG.pkg is missing3292 INFO: building PKG out00-PKG.pkg4784 INFO: checking EXE4784 INFO: rebuilding out00-EXE.toc because BlogsToWordpress.exe missing4786 INFO: building EXE from out00-EXE.toc4793 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

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,看看效果。

结果直接出错:

D:\tmp\tmp_dev_root\python\tutorial_summary\make_exe\pyinstaller-2.0\BlogsToWordpress\dist>BlogsToWordpress.exeTraceback (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.

去试试:

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\BlogsToWordpress\libs\thirdparty;D:\tmp\tmp_dev_root\python\tutorial_summary\make_exe\BlogsToWordpress\libs\thirdparty\chardet; ..\BlogsToWordpress\BlogsToWordpress.py18 INFO: wrote D:\tmp\tmp_dev_root\python\tutorial_summary\make_exe\pyinstaller-2.0\BlogsToWordpress\BlogsToWordpress.spec33 INFO: Testing for ability to set icons, version resources...36 INFO: ... resource update available39 INFO: UPX is not available.674 INFO: checking Analysis677 INFO: building because pathex changed679 INFO: running Analysis out00-Analysis.toc680 INFO: Adding Microsoft.VC90.CRT to dependent assemblies of final executable733 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.manifest736 INFO: Searching for file msvcr90.dll736 INFO: Found file C:\Windows\WinSxS\amd64_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.21022.8_none_750b37ff97f4f68b\msvcr90.dll738 INFO: Searching for file msvcp90.dll739 INFO: Found file C:\Windows\WinSxS\amd64_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.21022.8_none_750b37ff97f4f68b\msvcp90.dll740 INFO: Searching for file msvcm90.dll743 INFO: Found file C:\Windows\WinSxS\amd64_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.21022.8_none_750b37ff97f4f68b\msvcm90.dll812 INFO: Analyzing D:\tmp\tmp_dev_root\python\tutorial_summary\make_exe\pyinstaller-2.0\support\_pyi_bootstrap.py1512 INFO: Analyzing D:\tmp\tmp_dev_root\python\tutorial_summary\make_exe\pyinstaller-2.0\PyInstaller\loader\archive.py1578 INFO: Analyzing D:\tmp\tmp_dev_root\python\tutorial_summary\make_exe\pyinstaller-2.0\PyInstaller\loader\carchive.py1648 INFO: Analyzing D:\tmp\tmp_dev_root\python\tutorial_summary\make_exe\pyinstaller-2.0\PyInstaller\loader\iu.py1667 INFO: Analyzing ..\BlogsToWordpress\BlogsToWordpress.py3016 INFO: Hidden import 'encodings' has been found otherwise3016 INFO: Looking for run-time hooks3018 INFO: Analyzing rthook D:\tmp\tmp_dev_root\python\tutorial_summary\make_exe\pyinstaller-2.0\support/rthooks/pyi_rth_encodings.py3670 INFO: Warnings written to D:\tmp\tmp_dev_root\python\tutorial_summary\make_exe\pyinstaller-2.0\BlogsToWordpress\build\pyi.win32\BlogsToWordpress\warnBlogsToWordpress.txt3674 INFO: checking PYZ3679 INFO: building because toc changed3679 INFO: building PYZ out00-PYZ.toc5713 INFO: checking PKG5716 INFO: building because D:\tmp\tmp_dev_root\python\tutorial_summary\make_exe\pyinstaller-2.0\BlogsToWordpress\build\pyi.win32\BlogsToWordpress\out00-PYZ.pyz changed5717 INFO: building PKG out00-PKG.pkg7163 INFO: checking EXE7164 INFO: rebuilding out00-EXE.toc because pkg is more recent7164 INFO: building EXE from out00-EXE.toc7167 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,但是还是有一些其他,可能要依赖的库:

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了。

然后此处,删掉旧的,重新执行一次:

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\BlogsToWordpress\libs\thirdparty;D:\tmp\tmp_dev_root\python\tutorial_summary\make_exe\BlogsToWordpress\libs\thirdparty\chardet; ..\BlogsToWordpress\BlogsToWordpress.py18 INFO: wrote D:\tmp\tmp_dev_root\python\tutorial_summary\make_exe\pyinstaller-2.0\BlogsToWordpress\BlogsToWordpress.spec33 INFO: Testing for ability to set icons, version resources...37 INFO: ... resource update available39 INFO: UPX is not available.684 INFO: checking Analysis684 INFO: building Analysis because out00-Analysis.toc non existent684 INFO: running Analysis out00-Analysis.toc685 INFO: Adding Microsoft.VC90.CRT to dependent assemblies of final executable740 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.manifest742 INFO: Searching for file msvcr90.dll743 INFO: Found file C:\Windows\WinSxS\amd64_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.21022.8_none_750b37ff97f4f68b\msvcr90.dll744 INFO: Searching for file msvcp90.dll745 INFO: Found file C:\Windows\WinSxS\amd64_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.21022.8_none_750b37ff97f4f68b\msvcp90.dll747 INFO: Searching for file msvcm90.dll750 INFO: Found file C:\Windows\WinSxS\amd64_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.21022.8_none_750b37ff97f4f68b\msvcm90.dll821 INFO: Analyzing D:\tmp\tmp_dev_root\python\tutorial_summary\make_exe\pyinstaller-2.0\support\_pyi_bootstrap.py1531 INFO: Analyzing D:\tmp\tmp_dev_root\python\tutorial_summary\make_exe\pyinstaller-2.0\PyInstaller\loader\archive.py1600 INFO: Analyzing D:\tmp\tmp_dev_root\python\tutorial_summary\make_exe\pyinstaller-2.0\PyInstaller\loader\carchive.py1672 INFO: Analyzing D:\tmp\tmp_dev_root\python\tutorial_summary\make_exe\pyinstaller-2.0\PyInstaller\loader\iu.py1692 INFO: Analyzing ..\BlogsToWordpress\BlogsToWordpress.py2903 INFO: Hidden import 'encodings' has been found otherwise2904 INFO: Looking for run-time hooks2905 INFO: Analyzing rthook D:\tmp\tmp_dev_root\python\tutorial_summary\make_exe\pyinstaller-2.0\support/rthooks/pyi_rth_PIL_Image.py2917 INFO: Analyzing rthook D:\tmp\tmp_dev_root\python\tutorial_summary\make_exe\pyinstaller-2.0\support/rthooks/pyi_rth_encodings.py3319 INFO: Warnings written to D:\tmp\tmp_dev_root\python\tutorial_summary\make_exe\pyinstaller-2.0\BlogsToWordpress\build\pyi.win32\BlogsToWordpress\warnBlogsToWordpress.txt3325 INFO: checking PYZ3326 INFO: rebuilding out00-PYZ.toc because out00-PYZ.pyz is missing3326 INFO: building PYZ out00-PYZ.toc5360 INFO: checking PKG5360 INFO: rebuilding out00-PKG.toc because out00-PKG.pkg is missing5361 INFO: building PKG out00-PKG.pkg6839 INFO: checking EXE6839 INFO: rebuilding out00-EXE.toc because BlogsToWordpress.exe missing6840 INFO: building EXE from out00-EXE.toc6842 INFO: Appending archive to EXE D:\tmp\tmp_dev_root\python\tutorial_summary\make_exe\pyinstaller-2.0\BlogsToWordpress\dist\BlogsToWordpress.exeD:\tmp\tmp_dev_root\python\tutorial_summary\make_exe\pyinstaller-2.0>

虽然结果警告中,也还是有PIL:

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\tokeni

声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。

相关文章