Closed bw7715 closed 6 months ago
You can test the patch in the latest development build (dev63):
pip install --force --no-cache --pre --extra-index-url https://marcelotduarte.github.io/packages/ cx_Freeze
With this patch, the use of --packages can be removed. Tested the sample with torch 2.1 and 2.2 (torchvision 0.16 and 0.17).
Has anything changed in the order of arguments in the cx-freeze command?
When I run the current version the freeze starts,
but when I run the developer version (6.16.0.dev63) I get an error: invalid command name 'project.py'
cxfreeze --script=project.py
quando instalo essa versao dev63, resolve o problema do "could not get source code". Porém, aparece o problema "module 'abc' has no attribute ' file '" como resolver? isso é usando o easyocr, que também usa o torch (2.2.1) e torchvision 0.17.1
Thank you with 6.16.0.dev63 the torchvision 0.17.1 works.
I updated my freezer script.
The old one:
%FREEZER_EXE_PATH% -O -OO --include-msvcr --target-dir="%TARGET_DIR%" --target-name=%TARGET_NAME% --packages=%PACKAGES% project.py
The new one:
%FREEZER_EXE_PATH% --include-msvcr build --build-exe="%TARGET_DIR%" --target-name=%TARGET_NAME% --script=project.py
But I'm not sure where to put the -O -OO
parameters?
@MarceloUnlibreProjects Depois vou dar uma olhada, vou pegar um exemplo do easyocr.
@bw7715 Use:
cxfreeze --target-name=%TARGET_NAME% --script=project.py build_exe -OO --include-msvcr --build-exe="%TARGET_DIR%"
For more info:
cxfreeze --help
cxfreeze build_exe --help
With cxfreeze --target-name=%TARGET_NAME% --script=project.py build_exe -OO --include-msvcr --build-exe="%TARGET_DIR%"
I get an error:
ValueError: invalid literal for int() with base 10: 'O'
running build_exe
Traceback (most recent call last):
File "C:\Program Files\Python39\lib\runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Program Files\Python39\lib\runpy.py", line 87, in _run_code
exec(code, run_globals)
File "C:\Project\p39_torch221\_build\venv\Scripts\cxfreeze.exe\__main__.py", line 7, in <module>
File "C:\Project\p39_torch221\_build\venv\lib\site-packages\cx_Freeze\cli.py", line 226, in main
setup(
File "C:\Project\p39_torch221\_build\venv\lib\site-packages\cx_Freeze\__init__.py", line 69, in setup
return setuptools.setup(**attrs)
File "C:\Project\p39_torch221\_build\venv\lib\site-packages\setuptools\__init__.py", line 103, in setup
return distutils.core.setup(**attrs)
File "C:\Project\p39_torch221\_build\venv\lib\site-packages\setuptools\_distutils\core.py", line 185, in setup
return run_commands(dist)
File "C:\Project\p39_torch221\_build\venv\lib\site-packages\setuptools\_distutils\core.py", line 201, in run_commands
dist.run_commands()
File "C:\Project\p39_torch221\_build\venv\lib\site-packages\setuptools\_distutils\dist.py", line 969, in run_commands
self.run_command(cmd)
File "C:\Project\p39_torch221\_build\venv\lib\site-packages\setuptools\dist.py", line 963, in run_command
super().run_command(command)
File "C:\Project\p39_torch221\_build\venv\lib\site-packages\setuptools\_distutils\dist.py", line 987, in run_command
cmd_obj.ensure_finalized()
File "C:\Project\p39_torch221\_build\venv\lib\site-packages\setuptools\_distutils\cmd.py", line 111, in ensure_finalized
self.finalize_options()
File "C:\Project\p39_torch221\_build\venv\lib\site-packages\cx_Freeze\command\build_exe.py", line 249, in finalize_options
self.optimize = int(self.optimize)
ValueError: invalid literal for int() with base 10: 'O'
I replaced -O
and -OO
with -O1
and -O2
and them freezing start but I get an error:
copying C:\Project\p39_torch221\_build\venv\lib\site-packages\torch\fx\config.py -> C:\Project\p39_torch221\_build\out\lib\torch\fx\config.py
copying C:\Project\p39_torch221\_build\venv\lib\site-packages\torch\fx\experimental\_config.py -> C:\Project\p39_torch221\_build\out\lib\torch\fx\experimental\_config.py
Traceback (most recent call last):
File "C:\Project\p39_torch221\_build\venv\Lib\site-packages\cx_Freeze\initscripts\__startup__.py", line 132, in run
module_init.run(name + "__main__")
File "C:\Project\p39_torch221\_build\venv\Lib\site-packages\cx_Freeze\initscripts\console.py", line 17, in run
exec(code, module_main.__dict__)
File "project.py", line 1, in <module>
import torchvision
File "C:\Project\p39_torch221\_build\venv\lib\site-packages\torchvision\__init__.py", line 5, in <module>
import torch
File "C:/Users/bw7715/OneDrive - Zebra Technologies/Projects/python_projects/cx_freeze_issues/p39_torch221/_build/venv/lib/site-packages/torch/__init__.py", line 1215, in <module>
from .storage import _StorageBase, TypedStorage, _LegacyStorage, UntypedStorage, _warn_typed_storage_removal
File "C:\Project\p39_torch221\_build\venv\lib\site-packages\torch\storage.py", line 14, in <module>
import numpy as np
File "C:\Project\p39_torch221\_build\venv\lib\site-packages\numpy\__init__.py", line 173, in <module>
from . import core
File "C:\Project\p39_torch221\_build\venv\lib\site-packages\numpy\core\__init__.py", line 24, in <module>
from . import multiarray
File "C:\Project\p39_torch221\_build\venv\lib\site-packages\numpy\core\multiarray.py", line 86, in <module>
def empty_like(prototype, dtype=None, order=None, subok=None, shape=None):
File "C:\Project\p39_torch221\_build\venv\lib\site-packages\numpy\core\overrides.py", line 178, in decorator
return array_function_dispatch(
File "C:\Project\p39_torch221\_build\venv\lib\site-packages\numpy\core\overrides.py", line 158, in decorator
add_docstring(implementation, dispatcher.__doc__)
TypeError: argument docstring of add_docstring should be a str
numpy uses its docstring, so remove the optimization that it works. The optimization works like described here. See also: https://github.com/numpy/numpy/issues/13248#issuecomment-480412876
meu arquivo setup, está assim: (também tentei botando o easyocr em packages, mas deu no mesmo)
from cx_Freeze import setup, Executable
build_exe_options = {
"includes": ["requests", "psutil", "pyrebase", "win32gui", "cv2", "numpy", "socks", "windows_toasts", "pygetwindow", "bs4", "easyocr"]
}
executables = [
Executable(script=r"test1.py", base=None, icon='iapp.ico', target_name="exec1.exe"),
Executable(script=r"test2.py", base=None, icon='iapp.ico', target_name="exec2.exe")
]
setup( name = "test",
version = "0.8",
description = "test",
options = {"build_exe": build_exe_options},
executables = executables)
o erro só acontece quando tenta importar o módulo easyocr, dentro do exe
@MarceloUnlibreProjects You can test the patch (easyocr hook) in the latest development build (dev67):
pip install --force --no-cache --pre --extra-index-url https://marcelotduarte.github.io/packages/ cx_Freeze
Eu não consegui reproduzir o erro que vc teve, mas vi alguns problemas. Usei o seguinte para testar:
import easyocr
reader = easyocr.Reader(['ch_sim','en'], gpu=False)
result = reader.readtext('chinese.jpg')
print(result)
Se vc continuar tento erro, por favor abre uma issue e forneca um sample (ou modifique o que postei) que consiga reproduzir o erro.
Release 6.15.16 is out!
Describe the bug An error occurs when try to freeze a project with torchvision CUDA module.
To Reproduce (project.py)
(requirements.txt)
(freeze script)
Desktop (please complete the following information):
Additional context Add any other context about the problem here.