PyInstaller新手:你好世界
问题描述:
我想用PyInstaller v2.1创建一个简单的Hello World脚本(Python 2.7)的单个可执行文件。该脚本,hello.py,只有一个行:PyInstaller新手:你好世界
print 'Hello, World!'
我然后打开文件夹在命令窗口中包含的脚本,然后输入:
pyinstaller -F hello.py
我得到以下输出:
C:\Users\chris\workspace\HelloPy>pyinstaller -F hello.py
43 INFO: wrote C:\Users\chris\workspace\HelloPy\hello.spec
66 INFO: Testing for ability to set icons, version resources...
79 INFO: ... resource update available
83 INFO: UPX is not available.
115 INFO: Processing hook hook-os
299 INFO: Processing hook hook-time
304 INFO: Processing hook hook-cPickle
402 INFO: Processing hook hook-_sre
585 INFO: Processing hook hook-cStringIO
721 INFO: Processing hook hook-encodings
741 INFO: Processing hook hook-codecs
1332 INFO: Extending PYTHONPATH with C:\Users\chris\workspace\HelloPy
1332 INFO: checking Analysis
1539 INFO: checking PYZ
1644 INFO: checking PKG
1655 INFO: building because C:\Users\chris\workspace\HelloPy\build\hello\hello.exe.manifest changed
1656 INFO: building PKG (CArchive) out00-PKG.pkg
7801 INFO: checking EXE
7803 INFO: rebuilding out00-EXE.toc because pkg is more recent
7803 INFO: building EXE from out00-EXE.toc
7809 INFO: Appending archive to EXE C:\Users\chris\workspace\HelloPy\dist\hello.exe
build和dist文件夹按照预期创建,就像可执行文件一样。我尝试运行它,并得到下面的输出:
C:\Users\chris\workspace\HelloPy>cd dist
C:\Users\chris\workspace\HelloPy\dist>hello
WARNING: file already exists but should not: C:\Users\chris\AppData\Local\Temp\_MEI58962\include\pyconfig.h
Hello, World!
如果我运行pyinstaller代替,而不单可执行开关,即没有-F然后我没有得到“警告:文件已经存在”
我可能错过了一些非常明显的东西,但是我已经搜索过,并且似乎无法在其他任何地方找到此问题。任何帮助或指向其他地方的解决方案将非常感激。
答
有报PyInstaller队here指向此票SO回答作为一种解决方法: Pyinstaller --onefile warning pyconfig.h when importing scipy or scipy.signal
您修改与以下块的规范文件下a=Analysis
行:
for d in a.datas:
if 'pyconfig' in d[0]:
a.datas.remove(d)
break
这应该适用于你,因为它似乎最适用。
我个人更喜欢py2exe。这里是一个链接到“你好,世界”的例子做到完全相同的事情,你试图实现:http://www.py2exe.org/index.cgi/Tutorial