I am using the auto py to exe library to pass a file from python to .exe . But when converting test.py I get an error and it gives me this Traceback that I don't know what it could be due to.
File "c:\python\python37\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 1638, in _find_head_package
target_module_headname, target_package_name, source_package)
File "c:\python\python37\lib\site-packages\PyInstaller\depend\analysis.py", line 382, in _safe_import_module
module_basename, module_name, parent_package)
File "c:\python\python37\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2055, in _safe_import_module
module_name, file_handle, pathname, metadata)
File "c:\python\python37\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2093, in _load_module
m = self._load_package(fqname, pathname, packagepath)
File "c:\python\python37\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2912, in _load_package
self._load_module(fqname, fp, buf, stuff)
File "c:\python\python37\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2105, in _load_module
co = compile(contents, pathname, 'exec', ast.PyCF_ONLY_AST, True)
ValueError: source code string cannot contain null bytes
It is a longer error trace but I put only part of it. I put the project structure in which I only use the img package , the other python files I don't use, I just want to pass the tests.py . mainClass and preprocessing I don't use them at all. What is causing this error?
The problem seems to be the existence of "null" bytes, that is, with the ascii value
0x00
inside the source file, if you don't have a linux you can use the python console itself to eliminate them.I have created a file test.py with a character
0x00
to reproduce the errorA file is created the
prueba2.py
same asprueba.py
but without the null characters, I do not replace it directlyprueba.py
for security reasons, but once it is verified that it is OK, it should be replaced.By the way, I recommend that you use the WSL on Windows to have a linux with its commands that helps in certain situations, especially if you are developing