Run Python file/script in React Native

Viewed 621

Is there a way to run a Python script or file in a React Native app?

I've tried successfully to run a Python script in a node.js file with the following methods, but these methods break when I try them with React native:

I followed this tutorial to run Python in Node.js using child_process. This code worked in a standalone Node.js file, but when run with the React Native app I got an error saying the child_process module couldn't be resolved even after I imported it.

I also tried this tutorial to run Python scripts in Node.js using the npm module python-shell. Again, this code works in a standalone Node.js file, but when run with the React Native app, this error came up: "undefined Unable to resolve module 'events' from 'node_modules\python-shell\index.js"

Can you please advise me on how I could run a Python script in React Native or how I could resolve the above errors? Thank you!

0 Answers
Related