KeyError: 'CITRINE_KEY issue

44 views
Skip to first unread message

Houssam Houssam

unread,
Jun 1, 2019, 5:57:43 PM6/1/19
to matminer
from matminer.data_retrieval.retrieve_Citrine import CitrineDataRetrieval
from matminer.data_retrieval.retrieve_MP import MPDataRetrieval

df_citrine = CitrineDataRetrieval().get_dataframe(formula='Si', property='band gap', data_type='EXPERIMENTAL')
df_mp = MPDataRetrieval().get_dataframe(criteria='Si', properties=['band_gap'])


raceback (most recent call last):
File "C:/Users/Houssam/PycharmProjects/untitled2/eee.py", line 4, in <module>
df_citrine = CitrineDataRetrieval().get_dataframe(formula='Si', property='band gap', data_type='EXPERIMENTAL')
File "C:\Users\Houssam\miniconda3\lib\site-packages\matminer\data_retrieval\retrieve_Citrine.py", line 48, in __init__
api_key = os.environ["CITRINE_KEY"]
File "C:\Users\Houssam\miniconda3\lib\os.py", line 678, in __getitem__
raise KeyError(key) from None
KeyError: 'CITRINE_KEY'

Qi Wang

unread,
Jun 1, 2019, 7:27:08 PM6/1/19
to matminer
Hi Houssam, 

To instantiate CitrineDataRetrieval or MPDataRetrieval, you need to provide a Citrine or Materials Project API key. Please create an account in the website and find your API key by visiting the account settings or dashboard page:

You can then add your api_key when instantiating the classes:
cdr = CitrineDataRetrieval(api_key='your api_key')
mpdr = MPDataRetrieval(api_key='your api_key')

In addition, there are some issues in your example usage of CitrineDataRetrieval get_dataframe. For the provided example, it would be something like this:
df_citrine = cdr.get_dataframe(criteria={"formula": "Si", "data_type": "EXPERIMENTAL"}, properties=["Band gap"])
Please find more in the docs of CitrineDataRetrieval. 

Best,
Qi

Anubhav Jain

unread,
Jun 1, 2019, 8:27:27 PM6/1/19
to matm...@googlegroups.com

Houssam Houssam

unread,
Jun 1, 2019, 10:29:51 PM6/1/19
to matminer
HI
i missing that thanks

Houssam Houssam

unread,
Jun 1, 2019, 10:31:11 PM6/1/19
to matminer
thanks Qi 
its working
Reply all
Reply to author
Forward
0 new messages