# 安装 > pip install pyinstaller # 升级模块版本 > pip install --upgrade pyinstaller
# 安装成功时打印 Successfully installed pyinstaller-4.5.1
# -F 产生单个的可执行文件 # cmd 命令行路径为文件目录:Z:\package\files, 生成文件存放在Z:\package\files Z:\package\files> pyinstaller -F protion.py # -D 产生一个目录(包含多个文件)作为可执行程序 # cmd命令行路径非文件目录,生成文件存放在路径 Z:\ 下 Z:\> pyinstaller -D Z:\xxx\xxx\protion.py
> pyinstaller -F protion.py PyInstaller cannot check for assembly dependencies. Please install pywin32-ctypes. pip install pywin32-ctypes
> pip install pywin32-ctypes Looking in indexes: http://pypi.douban.com/simple Requirement already satisfied: pywin32-ctypes in c:\users\thinkpad\appdata\local\programs\python\python38-32\lib\site-packages (0.2.0)
# python安装模块路径进入Lib/site-packages/Pyinstaller中找到compat.py文件 示例:C:\Users\ThinkPad\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\PyInstaller compat.py # 打开文件搜索 win32ctypes if is_win: try: from win32ctypes.pywin32 import pywintypes # noqa: F401 from win32ctypes.pywin32 import win32api except ImportError: # This environment variable is set by setup.py # - It's not an error for pywin32 to not be installed at that point if not os.environ.get('PYINSTALLER_NO_PYWIN32_FAILURE'): raise SystemExit('PyInstaller cannot check for assembly dependencies.\n' 'Please install pywin32-ctypes.\n\n' 'pip install pywin32-ctypes\n') 将原有的: from win32ctypes.pywin32 import pywintypes # noqa: F401 from win32ctypes.pywin32 import win32api 修改为: #from win32ctypes.pywin32 import pywintypes # noqa: F401 #from win32ctypes.pywin32 import win32api import pywintypes import win32api
# 查看已安装需要升级的模块 > pip list -o # 如果存在新版本 便升级模块 > pip install --upgrade pyinstaller > pip install --upgrade pyinstaller-hooks-contrib > pip install --upgrade pygame # 升级陈宫运行 打包扔报错的话 按照方法一再重新配置一下