torrinworx / Cozy-Auto-Texture

A Blender add-on for generating free textures using the Stable Diffusion AI text to image model.
GNU General Public License v3.0
105 stars 6 forks source link

Add-on fails when restarted (CTRL+R) due to Tensor flow import issue. #1

Closed torrinworx closed 1 year ago

torrinworx commented 2 years ago

After installing the add-on successfully, and installing the dependencies, if the user (or developer) restarts the add-on with CTRL+R, Cozy Auto Texture reverts back to it's pre-dependency state: image

This error message also appears in the Blender System Console:

Reloading: <module 'bl_operators' from 'D:\\Program Files\\Blender Foundation\\Blender 3.2\\3.2\\scripts\\startup\\bl_operators\\__init__.py'>
Reloading: <module 'bl_ui' from 'D:\\Program Files\\Blender Foundation\\Blender 3.2\\3.2\\scripts\\startup\\bl_ui\\__init__.py'>
Reloading: <module 'keyingsets_builtins' from 'D:\\Program Files\\Blender Foundation\\Blender 3.2\\3.2\\scripts\\startup\\keyingsets_builtins.py'>
Reloading: <module 'nodeitems_builtins' from 'D:\\Program Files\\Blender Foundation\\Blender 3.2\\3.2\\scripts\\startup\\nodeitems_builtins.py'>
reloading addon: Cozy-Auto-Texture 1662345437.949952 1662345676.4157345 'D:\\Program Files\\Blender Foundation\\Blender 3.2\\3.2\\scripts\\addons\\Cozy-Auto-Texture\\__init__.py'
module changed on disk: 'D:\\Program Files\\Blender Foundation\\Blender 3.2\\3.2\\scripts\\addons\\Cozy-Auto-Texture\\__init__.py' reloading...
Exception in module register(): D:\Program Files\Blender Foundation\Blender 3.2\3.2\scripts\addons\Cozy-Auto-Texture\__init__.py
Traceback (most recent call last):
  File "D:\Program Files\Blender Foundation\Blender 3.2\3.2\scripts\modules\addon_utils.py", line 371, in enable
    mod.register()
  File "D:\Program Files\Blender Foundation\Blender 3.2\3.2\scripts\addons\Cozy-Auto-Texture\__init__.py", line 418, in register
    import_module(module_name=dependency.module, global_name=dependency.name)
  File "D:\Program Files\Blender Foundation\Blender 3.2\3.2\scripts\addons\Cozy-Auto-Texture\__init__.py", line 104, in import_module
    importlib.reload(globals()[global_name])
  File "D:\Program Files\Blender Foundation\Blender 3.2\3.2\python\lib\importlib\__init__.py", line 169, in reload
    _bootstrap._exec(spec, module)
  File "<frozen importlib._bootstrap>", line 619, in _exec
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "D:\Program Files\Blender Foundation\Blender 3.2\3.2\python\lib\site-packages\torch\__init__.py", line 74, in <module>
    if all([not os.path.exists(os.path.join(p, 'nvToolsExt64_1.dll')) for p in dll_paths]):
TypeError: all(): argument 'input' (position 1) must be Tensor, not list
gc.collect() -> 10367

The down side to this is that you need to delete all the dependencies, restart Blender, and fresh install the dependencies in order for Cozy Auto Texture to function with the new changes.

torrinworx commented 2 years ago

Another thing to note: when running the remove_dependencies() function to restart the dependency library, the following error appears:

PACKAGE TO UNINSTALL: torch
Found existing installation: torch 1.12.1
Uninstalling torch-1.12.1:
  Successfully uninstalled torch-1.12.1
ERROR: Exception:
Traceback (most recent call last):
  File "D:\Program Files\Blender Foundation\Blender 3.2\3.2\python\lib\site-packages\pip\_internal\cli\base_command.py", line 173, in _main
    status = self.run(options, args)
  File "D:\Program Files\Blender Foundation\Blender 3.2\3.2\python\lib\site-packages\pip\_internal\commands\uninstall.py", line 97, in run
    uninstall_pathset.commit()
  File "D:\Program Files\Blender Foundation\Blender 3.2\3.2\python\lib\site-packages\pip\_internal\req\req_uninstall.py", line 436, in commit
    self._moved_paths.commit()
  File "D:\Program Files\Blender Foundation\Blender 3.2\3.2\python\lib\site-packages\pip\_internal\req\req_uninstall.py", line 287, in commit
    save_dir.cleanup()
  File "D:\Program Files\Blender Foundation\Blender 3.2\3.2\python\lib\site-packages\pip\_internal\utils\temp_dir.py", line 184, in cleanup
    rmtree(self._path)
  File "D:\Program Files\Blender Foundation\Blender 3.2\3.2\python\lib\site-packages\pip\_vendor\tenacity\__init__.py", line 326, in wrapped_f
    return self(f, *args, **kw)
  File "D:\Program Files\Blender Foundation\Blender 3.2\3.2\python\lib\site-packages\pip\_vendor\tenacity\__init__.py", line 406, in __call__
    do = self.iter(retry_state=retry_state)
  File "D:\Program Files\Blender Foundation\Blender 3.2\3.2\python\lib\site-packages\pip\_vendor\tenacity\__init__.py", line 362, in iter
    raise retry_exc.reraise()
  File "D:\Program Files\Blender Foundation\Blender 3.2\3.2\python\lib\site-packages\pip\_vendor\tenacity\__init__.py", line 195, in reraise
    raise self.last_attempt.result()
  File "D:\Program Files\Blender Foundation\Blender 3.2\3.2\python\lib\concurrent\futures\_base.py", line 439, in result
    return self.__get_result()
  File "D:\Program Files\Blender Foundation\Blender 3.2\3.2\python\lib\concurrent\futures\_base.py", line 391, in __get_result
    raise self._exception
  File "D:\Program Files\Blender Foundation\Blender 3.2\3.2\python\lib\site-packages\pip\_vendor\tenacity\__init__.py", line 409, in __call__
    result = fn(*args, **kwargs)
  File "D:\Program Files\Blender Foundation\Blender 3.2\3.2\python\lib\site-packages\pip\_internal\utils\misc.py", line 135, in rmtree
    shutil.rmtree(dir, ignore_errors=ignore_errors, onerror=rmtree_errorhandler)
  File "D:\Program Files\Blender Foundation\Blender 3.2\3.2\python\lib\shutil.py", line 739, in rmtree
    return _rmtree_unsafe(path, onerror)
  File "D:\Program Files\Blender Foundation\Blender 3.2\3.2\python\lib\shutil.py", line 612, in _rmtree_unsafe
    _rmtree_unsafe(fullname, onerror)
  File "D:\Program Files\Blender Foundation\Blender 3.2\3.2\python\lib\shutil.py", line 617, in _rmtree_unsafe
    onerror(os.unlink, fullname, sys.exc_info())
  File "D:\Program Files\Blender Foundation\Blender 3.2\3.2\python\lib\shutil.py", line 615, in _rmtree_unsafe
    os.unlink(fullname)
PermissionError: [WinError 5] Access is denied: 'D:\\Program Files\\Blender Foundation\\Blender 3.2\\3.2\\python\\lib\\site-packages\\~=rch\\lib\\asmjit.dll'
Error: Python: Traceback (most recent call last):
  File "\Text", line 38, in <module>
  File "\Text", line 35, in remove_dependencies
  File "D:\Program Files\Blender Foundation\Blender 3.2\3.2\python\lib\subprocess.py", line 524, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['D:\\Program Files\\Blender Foundation\\Blender 3.2\\3.2\\python\\bin\\python.EXE', '-m', 'pip', 'uninstall', '-y', 'torch']' returned non-zero exit status 2.
torrinworx commented 2 years ago

Restarting the add-on with CTRL+R x2 seems to reset the add-on to a workable state, however the error message with Tensor will still be shown.

torrinworx commented 2 years ago

This error also appears when restarting the add-on twice:

Reloading: <module 'bl_operators' from 'D:\\Program Files\\Blender Foundation\\Blender 3.2\\3.2\\scripts\\startup\\bl_operators\\__init__.py'>
Reloading: <module 'bl_ui' from 'D:\\Program Files\\Blender Foundation\\Blender 3.2\\3.2\\scripts\\startup\\bl_ui\\__init__.py'>
Reloading: <module 'keyingsets_builtins' from 'D:\\Program Files\\Blender Foundation\\Blender 3.2\\3.2\\scripts\\startup\\keyingsets_builtins.py'>
Reloading: <module 'nodeitems_builtins' from 'D:\\Program Files\\Blender Foundation\\Blender 3.2\\3.2\\scripts\\startup\\nodeitems_builtins.py'>
Exception in module register(): D:\Program Files\Blender Foundation\Blender 3.2\3.2\scripts\addons\Cozy-Auto-Texture\__init__.py
Traceback (most recent call last):
  File "D:\Program Files\Blender Foundation\Blender 3.2\3.2\scripts\modules\addon_utils.py", line 371, in enable
    mod.register()
  File "D:\Program Files\Blender Foundation\Blender 3.2\3.2\scripts\addons\Cozy-Auto-Texture\__init__.py", line 447, in register
    import_module(module_name=dependency.module, global_name=dependency.name)
  File "D:\Program Files\Blender Foundation\Blender 3.2\3.2\scripts\addons\Cozy-Auto-Texture\__init__.py", line 112, in import_module
    importlib.reload(globals()[global_name])
  File "D:\Program Files\Blender Foundation\Blender 3.2\3.2\python\lib\importlib\__init__.py", line 169, in reload
    _bootstrap._exec(spec, module)
  File "<frozen importlib._bootstrap>", line 619, in _exec
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "D:\Program Files\Blender Foundation\Blender 3.2\3.2\python\lib\site-packages\torch\__init__.py", line 74, in <module>
    if all([not os.path.exists(os.path.join(p, 'nvToolsExt64_1.dll')) for p in dll_paths]):
TypeError: all(): argument 'input' (position 1) must be Tensor, not list
torrinworx commented 1 year ago

fixed with #7