1
$\begingroup$

I have a folder structure like this:

C: 
|_Blueprint
│   main.py
│
└───toolbox
        blueprint_tools.py

When I run this code in Blender's scripting text page:

from toolbox.blueprint_tools import dimension, array, modify

I get an error in the console

Traceback (most recent call last):
  File "\main.py", line 20, in <module>
ModuleNotFoundError: No module named 'toolbox'
Error: Python script failed, check the message in the system console

I swear, when I run this code (on other projects) outside of Blender this structure and code runs fine. But I get an error when running this script in Blender for testing out my Add-On.

If I compile the Blueprint folder into a .zip and install it everything works fine.... ?? I'm lost, could anyone please help me.

If I run the code like this: (added a . before toolbox for CWD)

from .toolbox.blueprint_tools import dimension, array, modify

Traceback (most recent call last):
  File "\main.py", line 20, in <module>
ImportError: attempted relative import with no known parent package
Error: Python script failed, check the message in the system console
$\endgroup$
9
  • 1
    $\begingroup$ __init__.py is missing for your module folder? python - What is init.py for? - Stack Overflow $\endgroup$
    – HikariTW
    Commented Dec 11, 2020 at 9:37
  • $\begingroup$ I've tried... it doesn't work. When I hit run script I get --> ModuleNotFoundError: No module named toolbox. $\endgroup$ Commented Dec 11, 2020 at 17:14
  • 1
    $\begingroup$ Why is it that everything works fine as is, if I install it. But when I try to run script it crashes..? $\endgroup$ Commented Dec 11, 2020 at 17:23
  • $\begingroup$ Adding __init__.py doesn't help. I have the same issue $\endgroup$
    – Amin Ya
    Commented Feb 17, 2023 at 19:45
  • $\begingroup$ Blender built-in text/script editor is just for testing code snippets and not a good option for fully functional add-on development. Use vs-code for this purpose Answered here: blender.stackexchange.com/questions/309332/… youtube.com/watch?v=YUytEtaVrrc $\endgroup$
    – Vinnie
    Commented Feb 5 at 8:18

0

You must log in to answer this question.

Browse other questions tagged .