The text you’ve linked comprises a python script, which is a text file that contains a series of python commands to be executed in sequence. You can use any text editor (vi from the video is a text editor) to copy/paste and edit the text you’ve linked and then type python oxidative_stability.py at the command line, which tells the python interpreter that you want to run all of the commands in the script.
If you’re not too keen on using text editors, you might consider using jupyter notebooks instead, which will enable you to type and edit multiple python commands in “cells” and execute them in sequence.
"--------------------------------------------------------------------------- ModuleNotFoundError Traceback (most recent call last) in () ----> 1 from pymatgen import Composition, Element, MPRester
** 2 from pymatgen.analysis.phase_diagram import PhaseDiagram**
** 3 **
** 4 if name == “main”:**
** 5 **
ModuleNotFoundError: No module named ‘pymatgen’ "
In other way, If I save the content as “oxidative_stability.py” in jupyter notebook and type " python oxidative_stability.py" command in “Anaconda Prompt”, I got this:
(my_pymatgen) C:\Users\Owner>python oxidative_stability.py C:\Users\Owner\Anaconda3\envs\my_pymatgen\lib\site-packages\pymatgen\analysis\reaction_calculator.py:336: FutureWarning: rcond parameter will change to the default of machine precision times max(M, N) where M and N are the input matrix dimensions. To use the future default and silence this warning we advise to pass rcond=None, to keep using the old, explicitly pass rcond=-1.
** coeffs, res, _, s = np.linalg.lstsq(f_mat.T, b)** FeP2 -8.466709382916667
I know that I did something silly but I don’t know how to get to the right way. Please help me.
Thank you in advance.
Absolutely, we’re happy to help. I believe the output you’ve linked indicates the command-line script is working. (The message you’re seeing, a FutureWarning, is a warning that’s related to some other codes that pymatgen uses that are undergoing a change and want to notify users). The output, “FeP2 -8.466709382916667” is from the last line of the script, print(FORMULA, max_chempot).
For the first problem, it sounds like the Jupyter environment and pymatgen aren’t installed in the same environment. If you’d like to fix it, maybe try clicking “Kernel->Change kernel” and seeing if there’s an option called “my_pymatgen”?. Anaconda enables you to install different environments with a different interpreter and installed packages, but the default jupyter will use the default python interpreter as its programming environment unless specified otherwise.
Thanks for your reply. Yes, you are right. I have tried the second way and practice with some examples from Gisthub then they works well.
However, for the first problem, I have clicked “Kernel->Change kernel” but I only see one option “Python3”, no “my_pymatgen”. I have installed “jupyter notebook” and “pymatgen” via Anaconda. I don’t know how to fix this. If you have any suggestion, please let me know. Thanks a lot.