原因 目录下有__init__ 但没有进行配置 结构如下 其中hallo.py import word print("hallo" + word.str) input() word.py str = "word" 其中 __init__.py文件没有配置 直接使用pyinstaller -F hallo.py -p word.py