I have a Python script that I named moduleA.py in the text editor. I ran the script by clicking the "Run Script" button. Then I expected to be able to import the module in the console with "import moduleA" but I get an error saying that the module does not exist.

How does one test functions etc. from a Python script in the text editor in the Python console?

  • $\begingroup$ @batFINGER Is this really the same? This is about testing a script in the Python Console, not importing modules to another script. $\endgroup$ Jun 1, 2019 at 17:39
  • $\begingroup$ @RayMairlot Prior to change could import py extension text editor script eg moduleA.py into the python console with import moduleA now instead use moduleA = bpy.data.texts["moduleA.py"].as_module() Don't necessarily need to run script from text editor first $\endgroup$
    – batFINGER
    Jun 2, 2019 at 5:20


Browse other questions tagged or ask your own question.