# Import script as a module

I have two files in a directory: "render.py" and "functions.py". From blender I use the text editor to run the "render.py" but the question is how to import "functions.py" to the file. This code fails.

import functions


How can I import in blender so that i can use functions from "functions.py" ?

### As a textblock

One way to do this is to add functions.py as a Text block. Make sure the Text block has a .py extension and you can import it directly using import functions. Described here: python-is-it-possible-to-import-another-text-block

### As a module

Otherwise, add functions.py to scripts/modules/some_name/functions.py, then

from some_name import functions


### A slight hack

There's probably an elegant way to do this, but if your stuck...

The render.py could load functions.py from a given path into a text block named the same:

# render.py #

import bpy

fp = '/home/zeffii/Desktop/functions.py'

def make_functions_local(fp):
texts = bpy.data.texts
t = texts.get('functions.py')
if not t:
t = texts.new('functions.py')

with open(fp) as module_file: