Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def bundle_and_import(module_name):
- this_plugin_path = os.path.dirname(__file__)
- module_path = os.path.join(this_plugin_path, module_name, "__init__.py")
- spec = importlib.util.spec_from_file_location(module_name, module_path)
- module = importlib.util.module_from_spec(spec)
- sys.modules[module_name] = module
- spec.loader.exec_module(module)
- bundle_and_import("torch")
- import torch
- The errors I get look like this:
- Vedo error:
- ERROR - [MainThread] UM.PluginRegistry._findPlugin [795]: Exception: Import error loading module MYPLUGINNAME
- ERROR - [MainThread] UM.PluginRegistry._findPlugin [795]: Traceback (most recent call last):
- ERROR - [MainThread] UM.PluginRegistry._findPlugin [795]: File "UM\PluginRegistry.py", line 793, in _findPlugin
- ERROR - [MainThread] UM.PluginRegistry._findPlugin [795]: spec.loader.exec_module(module)
- ERROR - [MainThread] UM.PluginRegistry._findPlugin [795]: File "<frozen importlib._bootstrap_external>", line 883, in exec_module
- ERROR - [MainThread] UM.PluginRegistry._findPlugin [795]: File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
- ERROR - [MainThread] UM.PluginRegistry._findPlugin [795]: File "C:\Users\MYUSERNAME\AppData\Roaming\cura\5.9\plugins\MYPLUGINNAME\__init__.py", line 4, in <module>
- ERROR - [MainThread] UM.PluginRegistry._findPlugin [795]: from . import MYPLUGINNAME
- ERROR - [MainThread] UM.PluginRegistry._findPlugin [795]: File "C:\Users\MYUSERNAME\AppData\Roaming\cura\5.9\plugins\MYPLUGINNAME\MYPLUGINNAME.py", line 98, in <module>
- ERROR - [MainThread] UM.PluginRegistry._findPlugin [795]: bundle_and_import("vedo", "vedo")
- 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
- ERROR - [MainThread] UM.PluginRegistry._findPlugin [795]: spec.loader.exec_module(module)
- ERROR - [MainThread] UM.PluginRegistry._findPlugin [795]: File "C:\Users\MYUSERNAME\AppData\Roaming\cura\5.9\plugins\MYPLUGINNAME\vedo\__init__.py", line 20, in <module>
- ERROR - [MainThread] UM.PluginRegistry._findPlugin [795]: from vtkmodules.vtkCommonCore import vtkVersion
- ERROR - [MainThread] UM.PluginRegistry._findPlugin [795]: ImportError: DLL load failed while importing vtkCommonCore: The specified module could not be found.
- ERROR - [MainThread] UM.PluginRegistry.removeCorruptedPluginMessage [577]: Exception: Error loading plugin MYPLUGINNAME:
- Torch error:
- ERROR - [MainThread] UM.PluginRegistry._findPlugin [795]: Exception: Import error loading module MYPLUGINNAME
- ERROR - [MainThread] UM.PluginRegistry._findPlugin [795]: Traceback (most recent call last):
- ERROR - [MainThread] UM.PluginRegistry._findPlugin [795]: File "UM\PluginRegistry.py", line 793, in _findPlugin
- ERROR - [MainThread] UM.PluginRegistry._findPlugin [795]: spec.loader.exec_module(module)
- ERROR - [MainThread] UM.PluginRegistry._findPlugin [795]: File "<frozen importlib._bootstrap_external>", line 883, in exec_module
- ERROR - [MainThread] UM.PluginRegistry._findPlugin [795]: File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
- ERROR - [MainThread] UM.PluginRegistry._findPlugin [795]: File "C:\Users\MYUSERNAME\AppData\Roaming\cura\5.9\plugins\MYPLUGINNAME\__init__.py", line 4, in <module>
- ERROR - [MainThread] UM.PluginRegistry._findPlugin [795]: from . import MYPLUGINNAME
- ERROR - [MainThread] UM.PluginRegistry._findPlugin [795]: File "C:\Users\MYUSERNAME\AppData\Roaming\cura\5.9\plugins\MYPLUGINNAME\MYPLUGINNAME.py", line 95, in <module>
- ERROR - [MainThread] UM.PluginRegistry._findPlugin [795]: bundle_and_import("torch", "torch")
- 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
- ERROR - [MainThread] UM.PluginRegistry._findPlugin [795]: spec.loader.exec_module(module)
- ERROR - [MainThread] UM.PluginRegistry._findPlugin [795]: File "C:\Users\MYUSERNAME\AppData\Roaming\cura\5.9\plugins\MYPLUGINNAME\torch\__init__.py", line 990, in <module>
- ERROR - [MainThread] UM.PluginRegistry._findPlugin [795]: raise ImportError(
- ERROR - [MainThread] UM.PluginRegistry._findPlugin [795]: ImportError: Failed to load PyTorch C extensions:
- ERROR - [MainThread] UM.PluginRegistry._findPlugin [795]: It appears that PyTorch has loaded the `torch/_C` folder
- ERROR - [MainThread] UM.PluginRegistry._findPlugin [795]: of the PyTorch repository rather than the C extensions which
- ERROR - [MainThread] UM.PluginRegistry._findPlugin [795]: are expected in the `torch._C` namespace. This can occur when
- ERROR - [MainThread] UM.PluginRegistry._findPlugin [795]: using the `install` workflow. e.g.
- ERROR - [MainThread] UM.PluginRegistry._findPlugin [795]: $ python setup.py install && python -c "import torch"
- ERROR - [MainThread] UM.PluginRegistry._findPlugin [795]:
- ERROR - [MainThread] UM.PluginRegistry._findPlugin [795]: This error can generally be solved using the `develop` workflow
- ERROR - [MainThread] UM.PluginRegistry._findPlugin [795]: $ python setup.py develop && python -c "import torch" # This should succeed
- ERROR - [MainThread] UM.PluginRegistry._findPlugin [795]: or by running Python from a different directory.
Advertisement
Add Comment
Please, Sign In to add comment