gpt4 book ai didi

python-3.x - 我无法为最简单的 'hello world' 示例创建 .exe

转载 作者:行者123 更新时间:2023-12-05 06:56:48 28 4
gpt4 key购买 nike

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

setup.py:

from distutils.core import setup
import py2exe

setup(console=['hello.py'])

你好.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)......但我不太明白它是什么。

谢谢!

-- 苹果

最佳答案

你只是输错了命令行标志,应该是: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

关于python-3.x - 我无法为最简单的 'hello world' 示例创建 .exe,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65050576/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com