This is a toy app to demo the functionality and use case for using the PyNode Node.js library to bridge calling Python code from within Node.js code. The demo app is a Express.js Web App that uses PyNode to call Python code that uses SciKit Learn and its California Housing Dataset to make a linear regression model for predicting home prices based off the 1990 US Census data.
Notes on Installing PyNode
As noted in the official PyNode repo only > Python3.6 is supported and only on Mac and Linux.
The approach I took to installing PyNode is as follows:
- create and activate Python 3.6 virtual environment
python3 -m venv venv source venv/bin/activate
- sym link python3-config to the virtual environment as "python-config"
ln -s /usr/local/bin/python3.6-config venv/bin/python-config
- npm install PyNode (be sure to have the Python virtual environment still active), also worth noting is that I was using Node v8.10
Running the Demo App
Install PyNode as described in the above section
Install Python dependencies (with Python virtual environment activated)
(venv) pip install -r requirements.txt
- Install Node.js dependencies
(venv) npm install
- Run Node.js / Express.js app
(venv) node server.js # or nodemon