问题描述
限时送ChatGPT账号..在具有和不具有管理员权限的 cmd 中执行命令 pyinstaller main.py
时,我收到 ValueError:源代码字符串不能包含空字节
.
I'm getting a ValueError: source code string cannot contain null bytes
when executing a command pyinstaller main.py
in a cmd both with and without administrator privileges.
Traceback (most recent call last):
File "c:\users\User\appdata\local\programs\python\python38\lib\runpy.py", line 192, in _run_module_as_main
return _run_code(code, main_globals, None,
File "c:\users\User\appdata\local\programs\python\python38\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Users\User\AppData\Local\Programs\Python\Python38\Scripts\pyinstaller.exe\__main__.py", line 7, in <module>
File "c:\users\User\appdata\local\programs\python\python38\lib\site-packages\PyInstaller\__main__.py", line 114, in run
run_build(pyi_config, spec_file, **vars(args))
File "c:\users\User\appdata\local\programs\python\python38\lib\site-packages\PyInstaller\__main__.py", line 65, in run_build
PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
File "c:\users\User\appdata\local\programs\python\python38\lib\site-packages\PyInstaller\building\build_main.py", line 734, in main
build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))
File "c:\users\User\appdata\local\programs\python\python38\lib\site-packages\PyInstaller\building\build_main.py", line 681, in build
exec(code, spec_namespace)
File "C:\Users\User\OneDrive\Pulpit\CODE\Python 3\PyGame Games\Game Of Pong\main.spec", line 30, in <module>
coll = COLLECT(exe,
File "c:\users\User\appdata\local\programs\python\python38\lib\site-packages\PyInstaller\building\api.py", line 698, in __init__
self.__postinit__()
File "c:\users\User\appdata\local\programs\python\python38\lib\site-packages\PyInstaller\building\datastruct.py", line 160, in __postinit__
self.assemble()
File "c:\users\User\appdata\local\programs\python\python38\lib\site-packages\PyInstaller\building\api.py", line 732, in assemble
fnm = checkCache(fnm, strip=self.strip_binaries,
File "c:\users\User\appdata\local\programs\python\python38\lib\site-packages\PyInstaller\building\utils.py", line 197, in checkCache
cache_index = load_py_data_struct(cacheindexfn)
File "c:\users\User\appdata\local\programs\python\python38\lib\site-packages\PyInstaller\utils\misc.py", line 233, in load_py_data_struct
return eval(f.read())
ValueError: source code string cannot contain null bytes
我尝试使用 Notepad++ 从我的代码中删除 NULL 字符,并尝试重新安装 pyinstaller,但问题仍然存在.
I tried deleting NULL characters from my code using Notepad++ and I tried reinstalling pyinstaller, yet the problem still persists.
推荐答案
我想通了.pyinstaller
似乎与最新版本的 Python 3
不兼容(截至 2020 年 5 月 24 日).我卸载了 Python 3.8.3 并安装了 Python 3.7.7,安装了我在 main.py
中使用的所有库,它工作正常!这么简单的解决方案.
I figured it out. It seems that pyinstaller
isn't compatible with the latest version of Python 3
(as of 24.05.2020). I uninstalled Python 3.8.3 and I installed Python 3.7.7, installed all of the libraries I was using in main.py
and it worked! Such a simple solution.
这篇关于PyInstaller“ValueError:源代码字符串不能包含空字节";的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
更多推荐
[db:关键词]
发布评论