{"repo":"extrabacon/python-shell","free":true,"listed":false,"github":"https://github.com/extrabacon/python-shell","clone":"git clone https://github.com/extrabacon/python-shell.git","description":"Run Python scripts from Node.js with simple (but efficient) inter-process communication through stdio","language":"TypeScript","stars":2163,"topics":["python","node","child-process","looking-for-maintainer","maintainer-wanted"],"license":null,"category":"dev-tools","readme_excerpt":"python-shell A simple way to run Python scripts from Node.js with basic but efficient inter-process communication and better error handling. Features - Reliably spawn Python scripts in a child process - Built-in text, JSON and binary modes - Custom parsers and formatters - Simple and efficient data transfers through stdin and stdout streams - Extended stack traces when an error is thrown Requirements First make sure you are able to run python3 (Mac/Linux) or python (Windows) from the terminal. If you are not then you might need to add it to the PATH. If you want to use a version of python not in the PATH you should specify options.pythonPath . Installation Documentation Running python code: If the script exits with a non-zero code, an error will be thrown. Note the use of imports! If you're not using typescript ಠ ಠ you can still get imports to work with this guide. Or you can use require like so: Running a Python script: If the script exits with a non-zero code, an error will be thrown. Running a Python script with arguments and options: Exchanging data between Node and Python: Use .send(message) to send a message to the Python script. Attach the message event to listen to messages emitted from the Python script. Use options.mode to quickly setup how data is sent and received between your Node and Python applications. - use text mode for exchanging lines of text ending with a newline character. - use json mode for exchanging JSON fragments - use binary mode for anything else ","default_branch":null,"files":null,"tree":[],"storefront":"/r/extrabacon","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/extrabacon/python-shell/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}