Apple silicon support for pymatgen

Hi,

I’ve tried using MPRester in apple silicon m1 system. However, any queries result in this:
REST query returned with error status code 405

I’ve tried this with python 3.8.12 and python 3.9.7, and pymatgen version was 2022.01.09 (the latest version at this moment). On the other hand, if I make a fresh conda environment (py3.9.7 same) and install the same pymatgen version (2022.01.09), I have no issues using the MPRester.

Is this because of the compatibility issue with apple silicon? Do you have any suggestions as to how I should fix this?

Thank you!!

Best,
KyuJung

Hi @KyuJung_Jun,

This should not be a result of Apple Silicon, but perhaps you can paste the line of code you were running and the full error message and maybe we can figure it out?

Best,

Matt

Hi Matthew,

Thanks for the quick reply!
Here is the code:

from pymatgen.ext.matproj import MPRester
mpr = MPRester("my_api_key")
material = mpr.get_entries_in_chemsys(['Li'])

And this same code runs only on intel mac, and not on apple silicon mac, both 2022.01.09 latest version and python 3.9 on a newly created conda environment.

The error message is as follows:

material = mpr.get_entries_in_chemsys([‘Li’])
Traceback (most recent call last):
File “/Users/kjun/anaconda3/envs/normal/lib/python3.9/site-packages/pymatgen/ext/matproj.py”, line 267, in _make_request
raise MPRestError(f"REST query returned with error status code {response.status_code}")
pymatgen.ext.matproj.MPRestError: REST query returned with error status code 405

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “”, line 1, in
File “/Users/kjun/anaconda3/envs/normal/lib/python3.9/site-packages/pymatgen/ext/matproj.py”, line 887, in get_entries_in_chemsys
entries = self.get_entries(
File “/Users/kjun/anaconda3/envs/normal/lib/python3.9/site-packages/pymatgen/ext/matproj.py”, line 537, in get_entries
data = self.query(criteria, props)
File “/Users/kjun/anaconda3/envs/normal/lib/python3.9/site-packages/pymatgen/ext/matproj.py”, line 1008, in query
num_results = self._make_request("/query", payload=count_payload, method=“POST”)
File “/Users/kjun/anaconda3/envs/normal/lib/python3.9/site-packages/pymatgen/ext/matproj.py”, line 271, in _make_request
raise MPRestError(msg)
pymatgen.ext.matproj.MPRestError: REST query returned with error status code 405. Content: b’\n405 Method Not Allowed\n

Method Not Allowed

\n

The method is not allowed for the requested URL.

\n’


Thank you for your help!

Best,
KyuJung

Just to update, the same code now works on Apple silicon machine, although no modification was done on code or environment. I’m not sure what was the reason, but it works now :slight_smile: