Search code examples
pythonpython-2.7paraview

Import home-made python function in paraview


I wanted to import basic functions in the python shell included in paraview. I tried:

import os
os.chdir('/path/to/my/directory')
import hello_world

Got the result:

Traceback (most recent call last):
File "<console>", line 1, in <module>
NameError: name 'hello_world' is not defined

while I have a hello_world.py in the directory …


Solution

  • Try this instead:

    import sys
    sys.path.append("/path/to/my/directory")
    
    import hello_world