Blender Stack Exchange is a question and answer site for people who use Blender to create 3D graphics, animations, or games. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Would it be possible to call Python codes I wrote in Text Editor from the Python console so that I can interact with it?

share|improve this question

If you name your script *.py in the text editor you can import it in the console as a module.

Beware - after you imported the script for the first time you can't import it again. If you make changes to the module you can use imp.reload or importlib.reload (for blender versions > 2.71 using python 3.4)

share|improve this answer

You can retrieve the Text datablock's text as string and run it in the context of the Python Console.

Here's an addon that makes it easy to do so:

Run Script in PyConsole (Menu)

Globals of your script will be added to the globals of the Python Console environment.

share|improve this answer
That's an useful addon. Is there an option to reset a console in blender? – pink vertex Jul 8 '14 at 10:28
As in resetting the scrollback, history and environment (globals and locals)? Well, you can remove members from locals() and globals() and bpy.ops.console.clear() resets the scrollback, but the history stays. I tried resetting the console by splitting and joining the area, but joining is buggy. – CoDEmanX Jul 8 '14 at 21:40

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.