我正在尝试用python创建适当的程序,可以在朋友的计算机上执行。为此,我使用cx_Freeze并按照此处列出的步骤How can I convert a .py to .exe for Python 3.6?
但是当我在提示符下键入python setup.py build时,它会给我以下错误。我用Google搜索了这个,但我不确定如何修复它。感谢您提前提供任何帮助。
PS C:\Users\jhgwa> python setup.py build
running build
running build_exe
creating directory build\exe.win-amd64-3.6
copying C:\Users\jhgwa\Anaconda3\lib\site-packages\cx_Freeze\bases\Console.exe -> build\exe.win-amd64-3.6\Announcement Keyword From Headline Puller.exe
copying C:\Users\jhgwa\Anaconda3\api-ms-win-crt-stdio-l1-1-0.dll -> build\exe.win-amd64-3.6\api-ms-win-crt-stdio-l1-1-0.dll
copying C:\Users\jhgwa\Anaconda3\python36.dll -> build\exe.win-amd64-3.6\python36.dll
copying C:\Users\jhgwa\Anaconda3\VCRUNTIME140.dll -> build\exe.win-amd64-3.6\VCRUNTIME140.dll
copying C:\Users\jhgwa\Anaconda3\api-ms-win-crt-math-l1-1-0.dll -> build\exe.win-amd64-3.6\api-ms-win-crt-math-l1-1-0.dll
copying C:\Users\jhgwa\Anaconda3\api-ms-win-crt-locale-l1-1-0.dll -> build\exe.win-amd64-3.6\api-ms-win-crt-locale-l1-1-0.dll
copying C:\Users\jhgwa\Anaconda3\api-ms-win-crt-string-l1-1-0.dll -> build\exe.win-amd64-3.6\api-ms-win-crt-string-l1-1-0.dll
copying C:\Users\jhgwa\Anaconda3\api-ms-win-crt-runtime-l1-1-0.dll -> build\exe.win-amd64-3.6\api-ms-win-crt-runtime-l1-1-0.dll
copying C:\Users\jhgwa\Anaconda3\api-ms-win-crt-convert-l1-1-0.dll -> build\exe.win-amd64-3.6\api-ms-win-crt-convert-l1-1-0.dll
copying C:\Users\jhgwa\Anaconda3\api-ms-win-crt-time-l1-1-0.dll -> build\exe.win-amd64-3.6\api-ms-win-crt-time-l1-1-0.dll
copying C:\Users\jhgwa\Anaconda3\api-ms-win-crt-environment-l1-1-0.dll -> build\exe.win-amd64-3.6\api-ms-win-crt-environment-l1-1-0.dll
copying C:\Users\jhgwa\Anaconda3\api-ms-win-crt-process-l1-1-0.dll -> build\exe.win-amd64-3.6\api-ms-win-crt-process-l1-1-0.dll
copying C:\Users\jhgwa\Anaconda3\api-ms-win-crt-heap-l1-1-0.dll -> build\exe.win-amd64-3.6\api-ms-win-crt-heap-l1-1-0.dll
copying C:\Users\jhgwa\Anaconda3\api-ms-win-crt-conio-l1-1-0.dll -> build\exe.win-amd64-3.6\api-ms-win-crt-conio-l1-1-0.dll
copying C:\Users\jhgwa\Anaconda3\api-ms-win-crt-filesystem-l1-1-0.dll -> build\exe.win-amd64-3.6\api-ms-win-crt-filesystem-l1-1-0.dll
Traceback (most recent call last):
File "C:\Users\jhgwa\Anaconda3\lib\site-packages\win32\lib\win32verstamp.py", line 120, in stamp
bits = [int(i) for i in ver.split(".")]
File "C:\Users\jhgwa\Anaconda3\lib\site-packages\win32\lib\win32verstamp.py", line 120, in <listcomp>
bits = [int(i) for i in ver.split(".")]
ValueError: invalid literal for int() with base 10: '<any number>'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "setup.py", line 22, in <module>
executables = executables
File "C:\Users\jhgwa\Anaconda3\lib\site-packages\cx_Freeze\dist.py", line 349, in setup
distutils.core.setup(**attrs)
File "C:\Users\jhgwa\Anaconda3\lib\distutils\core.py", line 148, in setup
dist.run_commands()
File "C:\Users\jhgwa\Anaconda3\lib\distutils\dist.py", line 955, in run_commands
self.run_command(cmd)
File "C:\Users\jhgwa\Anaconda3\lib\distutils\dist.py", line 974, in run_command
cmd_obj.run()
File "C:\Users\jhgwa\Anaconda3\lib\distutils\command\build.py", line 135, in run
self.run_command(cmd_name)
File "C:\Users\jhgwa\Anaconda3\lib\distutils\cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "C:\Users\jhgwa\Anaconda3\lib\distutils\dist.py", line 974, in run_command
cmd_obj.run()
File "C:\Users\jhgwa\Anaconda3\lib\site-packages\cx_Freeze\dist.py", line 219, in run
freezer.Freeze()
File "C:\Users\jhgwa\Anaconda3\lib\site-packages\cx_Freeze\freezer.py", line 617, in Freeze
self._FreezeExecutable(executable)
File "C:\Users\jhgwa\Anaconda3\lib\site-packages\cx_Freeze\freezer.py", line 226, in _FreezeExecutable
self._AddVersionResource(exe)
File "C:\Users\jhgwa\Anaconda3\lib\site-packages\cx_Freeze\freezer.py", line 167, in _AddVersionResource
stamp(fileName, versionInfo)
File "C:\Users\jhgwa\Anaconda3\lib\site-packages\win32\lib\win32verstamp.py", line 123, in stamp
raise ValueError("--version must be a.b.c.d (all integers) - got %r" % ver)
ValueError: --version must be a.b.c.d (all integers) - got '<any number>.0.0.0'
PS C:\Users\jhgwa>
答案 0 :(得分:3)
在setup.py
文件中,您必须将版本的值设置为字符串,在此示例代码中,我只需将其设置为&#34; 1.0&#34;:
setup(
name = '<app name>',
options = options,
version = "1.0",
description = '<any description>',
executables = executables
)
这应该足够了。