【问题标题】:I'm unable to create the .exe for the most simple 'hello world' example我无法为最简单的“hello world”示例创建 .exe
【发布时间】:2020-11-28 14:19:45
【问题描述】:

我已经在以前的构建机器上成功地使用了 py2exe,但现在我从头开始安装所有东西,无法运行最简单的示例:

setup.py

from distutils.core import setup
import py2exe
  
setup(console=['hello.py'])

hello.py

print("Hello World") 

命令:python3 setup.py py2exe 输出:

running py2exe

  1 missing Modules
  ------------------
? _posixshmem                         imported from multiprocessing.resource_tracker, multiprocessing.shared_memory
Building 'dist\hello.exe'.
error: [WinError 87] The parameter is incorrect.

dest\hello.exe 已生成(37 kB!),但运行时出现以下错误:

Could not locate script resource:The specified resource type cannot be found in the image file.
FATAL ERROR: Could not locate script

我安装的版本是:

python --version
Python 3.8.6

pip freeze
cachetools==4.1.1
future==0.18.2
numpy==1.19.3
opencv-python==4.4.0.46
pefile==2019.4.18
py2exe==0.10.1.0
pyreadline==2.1
pywin32==300

systeminfo
OS Name:                   Microsoft Windows 10 Pro
OS Version:                10.0.19041 N/A Build 19041
OS Manufacturer:           Microsoft Corporation
OS Configuration:          Standalone Workstation
OS Build Type:             Multiprocessor Free
Hotfix(s):                 6 Hotfix(s) Installed.
                           [01]: KB4580419
                           [02]: KB4561600
                           [03]: KB4577266
                           [04]: KB4580325
                           [05]: KB4586864
                           [06]: KB4586781
Hyper-V Requirements:      A hypervisor has been detected. Features required for Hyper-V will not be displayed.

我知道显然发生了一些奇怪的事情(我已经在这里遇到了 'numpy' 的问题:https://developercommunity.visualstudio.com/content/problem/1207405/fmod-after-an-update-to-windows-2004-is-causing-a.html)......但我不太明白它是什么。

谢谢!

-- Mac

【问题讨论】:

    标签: python-3.x py2exe


    【解决方案1】:

    你刚刚打错了命令行标志,应该是:python setup.py py2exe
    我在 Win7、Python 3.8.0 上运行良好:

    (py38) λ python setup.py py2exe
    running py2exe
    
      2 missing Modules
      ------------------
    ? _posixshmem                         imported from multiprocessing.resource_tracker, multiprocessing.shared_memory
    ? readline                            imported from cmd, code, pdb
    Building 'dist\hello.exe'.
    Building shared code archive 'dist\library.zip'.
    Copy c:\users\f3k\envs\py38\scripts\python38.dll to dist
    ...
    Copy DLL C:\Python38\DLLs\libffi-7.dll to dist\
    
    C:\temp
    (py38) λ dist\hello.exe
    Hello World
    

    【讨论】:

    • 抱歉 - 复制邮件时打错字了。我确实在命令行上正确输入了它。我已经编辑了帖子以纠正我的错字。
    猜你喜欢
    • 2020-03-08
    • 2013-10-14
    • 2012-04-29
    • 1970-01-01
    • 2017-08-04
    • 1970-01-01
    • 2018-09-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多