我为我的项目创建了一个.spec文件,PyInstaller运行顺利。但是,在运行.exe时,我的加载程序会出现以下情况:
Traceback (most recent call last):
File "<string>", line 14, in <module>
File "../../pyinstaller-2.0\PyInstaller\loader\iu.py", line 386, in importHook
File "../../pyinstaller-2.0\PyInstaller\loader\iu.py", line 480, in doimport
File "C:\Users\Spencer\workspace\nifty-prose-articulator\build\pyi.win32\Nifty
Prose Articulator\out00-PYZ.pyz\src.gui.main_window", line 25, in <module>
File "../../pyinstaller-2.0\PyInstaller\loader\iu.py", line 386, in importHook
File "../../pyinstaller-2.0\PyInstaller\loader\iu.py", line 480, in doimport
File "C:\Users\Spencer\workspace\nifty-prose-articulator\build\pyi.win32\Nifty
Prose Articulator\out00-PYZ.pyz\src.docx", line 15, in <module>
IOError: [Errno 2] No such file or directory: 'C:\\Users\\Spencer\\workspace\\ni
fty-prose-articulator\\build\\pyi.win32\\Nifty Prose Articulator\\out00-PYZ.pyz\
\OMMLToMathML.xsl'
除了它所指的XSLT之外,我还需要在运行时加载其他XML文件。
这是我的.spec文件:
a = Analysis(['src/main.py'],
pathex=['C:\\Users\\Spencer\\workspace\\nifty-prose-articulator'],
hiddenimports=[],
hookspath=None)
pyz = PYZ(a.pure)
exe = EXE(pyz,
a.scripts,
exclude_binaries=1,
name=os.path.join('build\\pyi.win32\\Nifty Prose Articulator', 'Nifty Prose Articulator.exe'),
debug=False,
strip=None,
upx=True,
console=True )
coll = COLLECT(exe,
a.binaries,
a.zipfiles,
a.datas + [('OMMLToMathML.xsl', 'C:\\Users\\Spencer\\workspace\\nifty-prose-articulator\\src\\docx\\OMMLToMathML.xsl', 'DATA')] ,
Tree(os.path.abspath('src/forms/icons')),
Tree(os.path.abspath('src/docx')),
strip=None,
upx=True,
name=os.path.join('dist', 'Nifty Prose Articulator'))
app = BUNDLE(coll,
name=os.path.join('dist', 'Nifty Prose Articulator.app'))
OMMLToMathML.xsl
位于C:\Users\Spencer\workspace\nifty-prose-articulator\src\docx
内。
.spec位于C:\Users\Spencer\workspace\nifty-prose-articulator\Nifty Prose Articulator.spec
。
我用来创建.exe的命令是:python ../../pyinstaller-2.0/utils/Build.py "Nifty Prose Articulator.spec"
正如您所看到的,我尝试单独添加文件,并使用Tree
(还有一些其他数据文件)隐式添加文件。
我一定是做错了什么,但是我已经把这个问题拖了很长时间。在此先感谢您的帮助!
答案 0 :(得分:0)
原来那个特定的样式表来自我忘记删除的一些不推荐使用的代码。其他一切都很好。