Guest User

Untitled

a guest
Mar 5th, 2025
17
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.30 KB | Software | 0 0
  1. def bundle_and_import(module_name):
  2. this_plugin_path = os.path.dirname(__file__)
  3. module_path = os.path.join(this_plugin_path, module_name, "__init__.py")
  4. spec = importlib.util.spec_from_file_location(module_name, module_path)
  5. module = importlib.util.module_from_spec(spec)
  6. sys.modules[module_name] = module
  7. spec.loader.exec_module(module)
  8. bundle_and_import("torch")
  9. import torch
  10.  
  11.  
  12. The errors I get look like this:
  13.  
  14. Vedo error:
  15. ERROR - [MainThread] UM.PluginRegistry._findPlugin [795]: Exception: Import error loading module MYPLUGINNAME
  16. ERROR - [MainThread] UM.PluginRegistry._findPlugin [795]: Traceback (most recent call last):
  17. ERROR - [MainThread] UM.PluginRegistry._findPlugin [795]: File "UM\PluginRegistry.py", line 793, in _findPlugin
  18. ERROR - [MainThread] UM.PluginRegistry._findPlugin [795]: spec.loader.exec_module(module)
  19. ERROR - [MainThread] UM.PluginRegistry._findPlugin [795]: File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  20. ERROR - [MainThread] UM.PluginRegistry._findPlugin [795]: File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  21. ERROR - [MainThread] UM.PluginRegistry._findPlugin [795]: File "C:\Users\MYUSERNAME\AppData\Roaming\cura\5.9\plugins\MYPLUGINNAME\__init__.py", line 4, in <module>
  22. ERROR - [MainThread] UM.PluginRegistry._findPlugin [795]: from . import MYPLUGINNAME
  23. ERROR - [MainThread] UM.PluginRegistry._findPlugin [795]: File "C:\Users\MYUSERNAME\AppData\Roaming\cura\5.9\plugins\MYPLUGINNAME\MYPLUGINNAME.py", line 98, in <module>
  24. ERROR - [MainThread] UM.PluginRegistry._findPlugin [795]: bundle_and_import("vedo", "vedo")
  25. ERROR - [MainThread] UM.PluginRegistry._findPlugin [795]: File "C:\Users\MYUSERNAME\AppData\Roaming\cura\5.9\plugins\MYPLUGINNAME\MYPLUGINNAME.py", line 72, in bundle_and_import
  26. ERROR - [MainThread] UM.PluginRegistry._findPlugin [795]: spec.loader.exec_module(module)
  27. ERROR - [MainThread] UM.PluginRegistry._findPlugin [795]: File "C:\Users\MYUSERNAME\AppData\Roaming\cura\5.9\plugins\MYPLUGINNAME\vedo\__init__.py", line 20, in <module>
  28. ERROR - [MainThread] UM.PluginRegistry._findPlugin [795]: from vtkmodules.vtkCommonCore import vtkVersion
  29. ERROR - [MainThread] UM.PluginRegistry._findPlugin [795]: ImportError: DLL load failed while importing vtkCommonCore: The specified module could not be found.
  30. ERROR - [MainThread] UM.PluginRegistry.removeCorruptedPluginMessage [577]: Exception: Error loading plugin MYPLUGINNAME:
  31.  
  32.  
  33.  
  34. Torch error:
  35. ERROR - [MainThread] UM.PluginRegistry._findPlugin [795]: Exception: Import error loading module MYPLUGINNAME
  36. ERROR - [MainThread] UM.PluginRegistry._findPlugin [795]: Traceback (most recent call last):
  37. ERROR - [MainThread] UM.PluginRegistry._findPlugin [795]: File "UM\PluginRegistry.py", line 793, in _findPlugin
  38. ERROR - [MainThread] UM.PluginRegistry._findPlugin [795]: spec.loader.exec_module(module)
  39. ERROR - [MainThread] UM.PluginRegistry._findPlugin [795]: File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  40. ERROR - [MainThread] UM.PluginRegistry._findPlugin [795]: File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  41. ERROR - [MainThread] UM.PluginRegistry._findPlugin [795]: File "C:\Users\MYUSERNAME\AppData\Roaming\cura\5.9\plugins\MYPLUGINNAME\__init__.py", line 4, in <module>
  42. ERROR - [MainThread] UM.PluginRegistry._findPlugin [795]: from . import MYPLUGINNAME
  43. ERROR - [MainThread] UM.PluginRegistry._findPlugin [795]: File "C:\Users\MYUSERNAME\AppData\Roaming\cura\5.9\plugins\MYPLUGINNAME\MYPLUGINNAME.py", line 95, in <module>
  44. ERROR - [MainThread] UM.PluginRegistry._findPlugin [795]: bundle_and_import("torch", "torch")
  45. ERROR - [MainThread] UM.PluginRegistry._findPlugin [795]: File "C:\Users\MYUSERNAME\AppData\Roaming\cura\5.9\plugins\MYPLUGINNAME\MYPLUGINNAME.py", line 72, in bundle_and_import
  46. ERROR - [MainThread] UM.PluginRegistry._findPlugin [795]: spec.loader.exec_module(module)
  47. ERROR - [MainThread] UM.PluginRegistry._findPlugin [795]: File "C:\Users\MYUSERNAME\AppData\Roaming\cura\5.9\plugins\MYPLUGINNAME\torch\__init__.py", line 990, in <module>
  48. ERROR - [MainThread] UM.PluginRegistry._findPlugin [795]: raise ImportError(
  49. ERROR - [MainThread] UM.PluginRegistry._findPlugin [795]: ImportError: Failed to load PyTorch C extensions:
  50. ERROR - [MainThread] UM.PluginRegistry._findPlugin [795]: It appears that PyTorch has loaded the `torch/_C` folder
  51. ERROR - [MainThread] UM.PluginRegistry._findPlugin [795]: of the PyTorch repository rather than the C extensions which
  52. ERROR - [MainThread] UM.PluginRegistry._findPlugin [795]: are expected in the `torch._C` namespace. This can occur when
  53. ERROR - [MainThread] UM.PluginRegistry._findPlugin [795]: using the `install` workflow. e.g.
  54. ERROR - [MainThread] UM.PluginRegistry._findPlugin [795]: $ python setup.py install && python -c "import torch"
  55. ERROR - [MainThread] UM.PluginRegistry._findPlugin [795]:
  56. ERROR - [MainThread] UM.PluginRegistry._findPlugin [795]: This error can generally be solved using the `develop` workflow
  57. ERROR - [MainThread] UM.PluginRegistry._findPlugin [795]: $ python setup.py develop && python -c "import torch" # This should succeed
  58. ERROR - [MainThread] UM.PluginRegistry._findPlugin [795]: or by running Python from a different directory.
  59.  
Advertisement
Add Comment
Please, Sign In to add comment