Hello,
I am a new user of mongoDB, which I need in order to write and run atomate workflows on an HPC. I have downloaded and activated an atomate environment on an HPC (TACC Stampede2) using Mamba, and I am having a great amount of trouble with library/package compatibility. I have written a simple script to get information from a Mongodb database, see below:
from pymongo import MongoClient
client = MongoClient()
client = MongoClient(host="141.212.130.128", port=27017, username='atomate_readwrite', password='mongo_readwrite', authSource='SunGroupCentral_atomatedb')
atomate_db = client.SunGroupCentral_atomatedb.tasks
result = atomate_db.find_one({"task_id": 1022})
from pymatgen.core.structure import Structure #Get structure from Atomate.
struct = Structure.from_dict(result['input']['structure'])
result['output']['energy']
When I try to run this script, an error is thrown in the import statement. I will note that this same error is thrown if I open python in the command prompt and simply type “import pymongo”:
Traceback (most recent call last):
File "QueryDB.py", line 2, in <module>
from pymongo import MongoClient
File "/home1/09341/jamesgil/mambaforge/envs/atomate_env/lib/python3.9/site-packages/pymongo/__init__.py", line 106
def has_c() -> bool:
^
SyntaxError: invalid syntax
I suspect that this is a compatibility issue, but I have been unsuccessful in trying to resolve it. I currently am using Python 3.9.16 and Pymongo 4.3.3. I tried downgrading to Pymongo 3.11.0, but encountered a similar error again:
Traceback (most recent call last):
File "QueryDB.py", line 2, in <module>
from pymongo import MongoClient
File "/home1/09341/jamesgil/mambaforge/envs/atomate_env/lib/python3.9/site-packages/pymongo/__init__.py", line 87, in <module>
from pymongo.collection import ReturnDocument
File "/home1/09341/jamesgil/mambaforge/envs/atomate_env/lib/python3.9/site-packages/pymongo/collection.py", line 29, in <module>
from pymongo import (common,
File "/home1/09341/jamesgil/mambaforge/envs/atomate_env/lib/python3.9/site-packages/pymongo/common.py", line 35, in <module>
from pymongo.ssl_support import (validate_cert_reqs,
File "/home1/09341/jamesgil/mambaforge/envs/atomate_env/lib/python3.9/site-packages/pymongo/ssl_support.py", line 27, in <module>
import pymongo.pyopenssl_context as _ssl
File "/home1/09341/jamesgil/mambaforge/envs/atomate_env/lib/python3.9/site-packages/pymongo/pyopenssl_context.py", line 27, in <module>
from OpenSSL import SSL as _SSL
File "/home1/09341/jamesgil/mambaforge/envs/atomate_env/lib/python3.9/site-packages/OpenSSL/__init__.py", line 8, in <module>
from OpenSSL import SSL, crypto
File "/home1/09341/jamesgil/mambaforge/envs/atomate_env/lib/python3.9/site-packages/OpenSSL/SSL.py", line 9, in <module>
from OpenSSL._util import (
File "/home1/09341/jamesgil/mambaforge/envs/atomate_env/lib/python3.9/site-packages/OpenSSL/_util.py", line 21
def text(charp: Any) -> str:
^
SyntaxError: invalid syntax
Does anyone have any idea what might be throwing this error and how I can begin to resolve it? Thanks in advance for the help.