# No such file or directory

**URL:** https://discourse.nodered.org/t/no-such-file-or-directory/1338
**Category:** General
**Created:** [4 July 2018 23:30 UTC](https://discourse.nodered.org/t/no-such-file-or-directory/1338 "2018-07-04T23:30:52Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![Tangental](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/tangental/32/1003_2.png) [@Tangental](https://discourse.nodered.org/u/Tangental)
#### Post date: [4 July 2018 23:30 UTC](https://discourse.nodered.org/t/no-such-file-or-directory/1338/1 "2018-07-04T23:30:52Z")

</div>

I have Docker Swarm with node-red running. I have used a simple flow to try and read a HelloWorld.py script [EXEC] with no joy. I had modified it to “cat /etc/pam.conf” and it works. I am sure I am missing something simple, any assistance would be appreciated.

Error:  
**payload: "python: can’t open file ‘/home/pi/HelloWorld.py’: [Errno 2] No such file or directory↵"**

Export of the flow:

`[{"id":"3f0a9383.02189c","type":"tab","label":"Flow 1"},{"id":"83d6a159.11f9a","type":"inject","z":"3f0a9383.02189c","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":100,"y":120,"wires":[["1683f7e8.ee1dd8"]]},{"id":"6c98bc6a.acd014","type":"debug","z":"3f0a9383.02189c","name":"","active":true,"console":"false","complete":"true","x":510,"y":120,"wires":[]},{"id":"1683f7e8.ee1dd8","type":"exec","z":"3f0a9383.02189c","command":"python -u /home/pi/HelloWorld.py","addpay":false,"append":"","useSpawn":false,"timer":"","name":"test","x":290,"y":200,"wires":[[],["6c98bc6a.acd014"],["6c98bc6a.acd014"]]}]`

```
pi@pi2:~ $ cat HelloWorld.py
#!/user/bin/python
# Hello World python Program
print "Hello World!";

pi@pi2:~ $ python HelloWorld.py
Hello World!
```

---

<div class="post-metadata">

### Author: ![YT2310](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/yt2310/32/35255_2.png) [@YT2310](https://discourse.nodered.org/u/YT2310)
#### Post date: [5 July 2018 08:19 UTC](https://discourse.nodered.org/t/no-such-file-or-directory/1338/2 "2018-07-05T08:19:23Z")

</div>

> [@Tangental](#):
>
> Export of the flow:
> 
> [{“id”:“3f0a9383.02189c”,“type”:“tab”,“label”:“Flow 1”},{“id”:“83d6a159.11f9a”,“type”:“inject”,“z”:“3f0a9383.02189c”,“name”:"",“topic”:"",“payload”:"",“payloadType”:“date”,“repeat”:"",“crontab”:"",“once”:false,“x”:100,“y”:120,“wires”:[[“1683f7e8.ee1dd8”]]},{“id”:“6c98bc6a.acd014”,“type”:“debug”,“z”:“3f0a9383.02189c”,“name”:"",“active”:true,“console”:“false”,“complete”:“true”,“x”:510,“y”:120,“wires”:},{“id”:“1683f7e8.ee1dd8”,“type”:“exec”,“z”:“3f0a9383.02189c”,“command”:“python -u /home/pi/HelloWorld.py”,“addpay”:false,“append”:"",“useSpawn”:false,“timer”:"",“name”:“test”,“x”:290,“y”:200,“wires”:[,[“6c98bc6a.acd014”],[“6c98bc6a.acd014”]]}]

Hello, use this button to Formate your code

 ![Unbenannt](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/9/9a73d3a4cbce23fa2553098602eb70cc05549bc6.JPG)

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [5 July 2018 08:37 UTC](https://discourse.nodered.org/t/no-such-file-or-directory/1338/3 "2018-07-05T08:37:10Z")

</div>

@Tangental you need to edit your previous post (use the pen icon at the bottom) and insert a line containing three back tick characters (to the left of the 1 key on my keyboard) before your flow and another such line after your flow. Then it will tell Discourse not to convert the quotes to smart quotes and we will be able to import it.

---

<div class="post-metadata">

### Author: ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)
#### Post date: [5 July 2018 09:50 UTC](https://discourse.nodered.org/t/no-such-file-or-directory/1338/4 "2018-07-05T09:50:42Z")

</div>

@Tangental

do you actually have the line ‘Hello World python Program’ in your program?  
Have you tried running the python program from the cli on the pi?

---

<div class="post-metadata">

### Author: ![Tangental](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/tangental/32/1003_2.png) [@Tangental](https://discourse.nodered.org/u/Tangental)
#### Post date: [5 July 2018 12:29 UTC](https://discourse.nodered.org/t/no-such-file-or-directory/1338/5 "2018-07-05T12:29:13Z")

</div>

Yes the code is like I copied it up there. I removed that line and displayed the results below from the cli.

```
pi@pi2:~ $ python HelloWorld.py
Hello World!

```

Thanks,

---

<div class="post-metadata">

### Author: ![Tangental](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/tangental/32/1003_2.png) [@Tangental](https://discourse.nodered.org/u/Tangental)
#### Post date: [5 July 2018 12:30 UTC](https://discourse.nodered.org/t/no-such-file-or-directory/1338/6 "2018-07-05T12:30:11Z")

</div>

Thanks I have updated the question.

---

<div class="post-metadata">

### Author: ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)
#### Post date: [5 July 2018 12:37 UTC](https://discourse.nodered.org/t/no-such-file-or-directory/1338/7 "2018-07-05T12:37:24Z")

</div>

I can’t help you with docker, but at least the python will now work without returning an error 😀

---

<div class="post-metadata">

### Author: ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)
#### Post date: [5 July 2018 13:16 UTC](https://discourse.nodered.org/t/no-such-file-or-directory/1338/8 "2018-07-05T13:16:17Z")

</div>

what user is docker running as ? If not running as Pi it may not have access to that directory.

---

<div class="post-metadata">

### Author: ![Tangental](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/tangental/32/1003_2.png) [@Tangental](https://discourse.nodered.org/u/Tangental)
#### Post date: [5 July 2018 23:46 UTC](https://discourse.nodered.org/t/no-such-file-or-directory/1338/9 "2018-07-05T23:46:21Z")

</div>

I dug into the permissions and tried multiple ways, until I found that the docker container did not have the file to be accessible.

so I had to copy the file to the container, using [Vlad's Docker Copy Example](https://forums.docker.com/t/will-docker-cp-command-work-for-copying-files-from-host-to-a-container/2022) I was able to make a copy in the context that Node-Red could access.

`pi@pi2:/home $ sudo docker container ls | grep mynodered | cut -d' ' -f1`  
`c22f8d1433e8`  
then add that to the docker command...  
`sudo cat /home/pi/HelloWorld.py | docker exec -i c22f8d1433e8 sh -c 'cat > /home/HelloWorld.py'`  
note the /home/pi/ did not exist, so I placed it in the root of the home folder.

one step closer...  
next I modified the [EXEC] to cat that file and it worked!

Then modified it to run the HelloWorld.py like:  
`python -u /home/HelloWorld.py`

```
msg : Object
object
_msgid: "f583bcb9.d7203"
topic: ""
payload: "Hello World!↵"

```

This worked!  
so a little more complicated than expected to get the python scripts available... but workable.

Now I have to find out how to sudo another python script so access the GPIO pins. ultrasonic.py 🙂
