Hi, I am working on a nodeJS application and I want to integrate a python script, as expected it works locally but returns an error as: {“error”:“Command failed: python3 fetch_stock_data.py AAPL 3mo 1d\n/bin/sh: line 1: python3: command not found\n”} for GET request to the backend.
It should rather give me a response from the python script and then display the data on the frontend.
This is the server code:
// Endpoint to fetch stock data
router.get(“/history”, async (req, res) => {
const { symbol = “AAPL”, period = “3mo”, interval = “1d” } = req.query;
Vercel is a serverless platform, which unlike your computer system doesn’t have all Runtimes (Node.js, Python, etc) at the same time. Because you are using Node.js the Vercel deployment will only have the Node.js runtime available to use.
You can solve this issue by creating a Python application out of this script and deploy it on Vercel as an HTTP API. This way the frontend application can communicate with the Python script directly.
Hi @anshumanb, thanks for the answer. I was able to use flask API for my python script and built a workaround for the logic.
Also, I’d like to know if static files are also overlooked by vercel environment?
Following is the error I get on my backend API in spite of having the stocks.csv in the right folder/path. which runs correct locally.
My application backend API works fine for all other requests but for the functions where it uses another static file stocks.csv it encounters and INTERNAL error and the logs display it as FILE NOT FOUND.