I'm trying to import data stored as a JSON. It works fine in stand-alone python, but I am having problems in Blender python console.
I have a folder
Applications/blender.app/Contents/Resources/2.74/scripts/addons/uhoh and in it I have
wowtest.py, a blank
test_data.txt which contains the JSON.
def wowtest(fname): import json print('hmmm.... will this work?') with open(fname, 'r') as infile: xdic = json.load(infile) return xdic
And this is what happens in Blender's python console:
>> import uhoh.wowtest as wow >>> wow.wowtest('test_data.txt') hmmm.... will this work? Traceback (most recent call last): File "<blender_console>", line 1, in <module> File "/Applications/blender.app/Contents/Resources/2.74/scripts/addons/uhoh/wowtest.py", line 9, in wowtest with open(fname, 'r') as infile: FileNotFoundError: [Errno 2] No such file or directory: 'test_data.txt'
I have put a second copy of
test_data' up one level (in/addons`) just in case, but this doesn't help. What am I missing?
NOTE: I will run this from a script next. If there are differences, please let me know.