I've set up a test MongoDb Atlas account, just one of the free ones and using the below code on my Ubuntu box I can successfully create users and also search for them.
When I try the exact same thing on my MacBook Air I get an SSL handshake as below.
pymongo.errors.ServerSelectionTimeoutError: SSL handshake failed: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:833),SSL handshake failed: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:833),SSL handshake failed: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:833)
import pymongo
client = pymongo.MongoClient("mongodb+srv://MYUSERNAME:MYPASSWORD@cluster0-ABCDEF.mongodb.net/test")
db = client.johnny
collection = db.myjohnnytest
example = {'name' : 'Johnny',
'email' : 'johnny@test.net'}
user_id = collection.insert_one(example).inserted_id
I found this answer which seemed like it was the key:
But I have since tried this and whether I follow it exactly or activate my virtualenv I get the following error:
Could not find an activated virtualenv (required). Traceback (most recent call last): File "", line 44, in File "", line 25, in main File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/subprocess.py", line 291, in check_call raise CalledProcessError(retcode, cmd) subprocess.CalledProcessError: Command '['/Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6', '-E', '-s', '-m', 'pip', 'install', '--upgrade', 'certifi']' returned non-zero exit status 3. logout Saving session... ...copying shared history... ...saving history...truncating history files... ...completed.