Python can't read the file

Joy's Avatar


02 Feb, 2016 04:23 PM

I try to open the text file as I follow the Str tutorial.
str = open("joy.txt").read()

rect(0,0,WIDTH, HEIGHT)


font("Helvetica", 13)
text("Heading", 20, 30)

However I've got this error:
Traceback (most recent call last):
File "/Users/Joy/Documents/NodeBox/", 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.

  1. Support Staff 1 Posted by Frederik De Ble... on 02 Feb, 2016 07:30 PM

    Frederik De Bleser's Avatar

    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.



  2. 2 Posted by Joy on 02 Feb, 2016 08:43 PM

    Joy's Avatar

    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.



  3. Support Staff 3 Posted by Frederik De Ble... on 03 Feb, 2016 11:28 AM

    Frederik De Bleser's Avatar

    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.

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:


Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts


? 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

Recent Discussions

16 May, 2024 02:11 AM
16 May, 2024 01:58 AM
14 May, 2024 01:29 AM
13 May, 2024 12:36 AM
12 May, 2024 07:46 PM


05 May, 2024 04:38 PM
03 May, 2024 06:50 AM
03 May, 2024 12:30 AM
03 May, 2024 12:09 AM
19 Apr, 2024 04:41 AM
16 Apr, 2024 06:18 PM