代码:
import cx_Freeze as f
exe = [f.Executable("C:\\Users\Administrator\\Desktop\\GAME bro\\game.py")]
f.setup(name="cars",options={"build exe":{"packages":["pygame","random","time"],"include_files":["C:\\Users\\Administrator\\Desktop\\GAME bro\\heloo.png"]}},executables=exe)
运行此代码时的结果:
running build
running build_exe
creating directory build\exe.win-amd64-3.6
copying C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\site-packages\cx_Freeze\bases\Console.exe -> build\exe.win-amd64-3.6\game.exe
copying C:\Users\Administrator\AppData\Local\Programs\Python\Python36\python36.dll -> build\exe.win-amd64-3.6\python36.dll
Traceback (most recent call last):
File "setup.py", line 5, in <module>
f.setup(name="cars",options={"build exe":{"packages":["pygame","random","time"],"include_files":["C:\\Users\\Administrator\\Desktop\\GAME bro\\heloo.png"]}},executables=exe)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\site-packages\cx_Freeze\dist.py", line 349, in setup
distutils.core.setup(**attrs)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\distutils\core.py", line 148, in setup
dist.run_commands()
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\distutils\dist.py", line 955, in run_commands
self.run_command(cmd)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\distutils\dist.py", line 974, in run_command
cmd_obj.run()
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\distutils\command\build.py", line 135, in run
self.run_command(cmd_name)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\distutils\cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\distutils\dist.py", line 974, in run_command
cmd_obj.run()
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\site-packages\cx_Freeze\dist.py", line 219, in run
freezer.Freeze()
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\site-packages\cx_Freeze\freezer.py", line 618, in Freeze
self._FreezeExecutable(executable)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\site-packages\cx_Freeze\freezer.py", line 227, in _FreezeExecutable
self._AddVersionResource(exe)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\site-packages\cx_Freeze\freezer.py", line 166, in _AddVersionResource
trademarks = exe.trademarks)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\site-packages\cx_Freeze\freezer.py", line 751, in __init__
parts = version.split(".")
AttributeError: 'NoneType' object has no attribute 'split'
所以这就是问题所以有人可以帮助我
所以尝试运行此代码
我在Windows 10操作系统中
这个问题的主要部分是这个部分:
AttributeError: 'NoneType' object has no attribute 'split'
答案 0 :(得分:3)
NoneType
对象表示:
在您的情况下,version.split(".")
失败,因为未设置“版本”。似乎需要将“版本”添加到f.setup()
调用中,即这应该有效:
f.setup(
name="cars",
options={
"build exe":{"packages":["pygame","random","time"],
"include_files":["C:\\Users\\Administrator\\Desktop\\GAME bro\\heloo.png"]}},
executables=exe,
version="1.0.0"
)
请尝试一下,如果有帮助请告诉我们。