【问题标题】:PyInstaller newbie: hello worldPyInstaller 新手:你好世界
【发布时间】:2014-10-24 08:53:44
【问题描述】:

我正在尝试使用 PyInstaller v2.1 从一个简单的 hello world 脚本 (Python 2.7) 创建一个可执行文件。脚本 hello.py 只有一行:

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,那么我不会收到“警告:文件已存在”

我可能遗漏了一些非常明显的东西,但我已经四处搜索,似乎在其他任何地方都找不到这个问题。任何帮助或指向其他解决方案的指针将不胜感激。

【问题讨论】:

    标签: python python-2.7 pyinstaller


    【解决方案1】:

    向 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。这是一个“Hello, World”示例的链接,与您尝试实现的目标完全相同:http://www.py2exe.org/index.cgi/Tutorial

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-11-19
      • 1970-01-01
      • 2015-01-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多