Python can't read the file
I try to open the text file as I follow the Str tutorial.
str = open("joy.txt").read()
fill(0.2)
rect(0,0,WIDTH, HEIGHT)
fill(1)
font("Helvetica", 13)
text("Heading", 20, 30)
However I've got this error:
Traceback (most recent call last):
File
"/Users/Joy/Documents/NodeBox/NodeBox.app/Contents/Resources/python/nodebox/gui/mac/__init__.py",
line 361, in _execScript exec self._code in self.namespace File "",
line 1, in IOError: [Errno 2] No such file or directory:
'joy.txt'
I use Nodebox Version 1.9.7rc1 (1) on OSX 10.11.3
Thank you.
Keyboard shortcuts
Generic
? | Show this help |
---|---|
ESC | Blurs the current field |
Comment Form
r | Focus the comment reply box |
---|---|
^ + ↩ | Submit the comment |
You can use Command ⌘
instead of Control ^
on Mac
Support Staff 1 Posted by Frederik De Ble... on 02 Feb, 2016 07:30 PM
Hi Joy,
This can happen when your NodeBox file is not saved yet.
NodeBox looks for files relative to the current .py file. However, if you haven't saved your file first, NodeBox doesn't know where to look. Try saving the script first, then placing the txt file in the same folder as the script.
Best,
F
2 Posted by Joy on 02 Feb, 2016 08:43 PM
Hi Frederik,
Thank you. I have saved the file and change the path to '/Users/Joy/Documents/NodeBox/sandbox/joy.txt'
And it works now.
Best,
Joy
Support Staff 3 Posted by Frederik De Ble... on 03 Feb, 2016 11:28 AM
I just checked and it isn't mentioned anywhere in the documentation, so it would be very hard for you to just know that :-)
I'll see if I can update it.