I'm "spawning" a python script from my NodeJs server code using
var spawn = require('child_process').spawn;
var python_process = spawn('python', ['server/matcher/matcher.py'])
My python code is supposed to process some data fetched from my MongoDB collection so I need to access my database. I have already installed pymongo and dnspython and I'm sure of that because whenever I run the installation command for either of them I get a
Requirement already satisfied: dnspython in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages (1.16.0)
However, whenever I try to run my code I get the error
pymongo.errors.ConfigurationError: The "dnspython" module must be installed to use mongodb+srv:// URIs
I access my database as I usually do and as instructed in the documentation
from pymongo import MongoClient
client = MongoClient(<connection string>)
db = client.<db name>
users = db.users.find({})
I realize this is an environment issue because the same code ran correctly and connected to Mongo successfully when I ran it in PyCharm, but I'm not sure how to make it work in the NodeJs child process.