Skip to content Skip to sidebar Skip to footer

Python "send2pd" Doesn't Reach Pure Data's "netreceive"

I need to send messages from Python to Pure Data, so I followed this article. It was working fine until one day suddenly it stopped working. Pure Data doesn't receive anything anym

Solution 1:

How would Python know that it should look for executables in /Users/path_to_pure_data/PureData.app/Contents/Resources/bin/?

For security (and perfomance) reasons, the system will only search for executables in a few select locations, that are defined in the PATH environment variable.

You could either add /Users/path_to_pure_data/PureData.app/Contents/Resources/bin/ to your PATH, or put pdsend into a path that is already searched for.

However, this seems to be an overkill in any case, as calling an external application is rather costly, and using os.system is probably one of the worst options.

Python is a powerful programming language, and it is very easy to build the client code in Python itself. Eg this code does not have any external dependencies, performs faster, and is safer (and I'd say. it's easier to read as well):

import socket

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(("localhost", 3000))
s.sendall(b'1;')
s.close()

Post a Comment for "Python "send2pd" Doesn't Reach Pure Data's "netreceive""