Closed Andrew-S-Rosen closed 3 years ago
Thank you very much for your help. The problem does appear upon calling the OrbitalFieldMatrix function from matminer.And I tried the methods you gave, there are still the following problems:
Traceback (most recent call last):
File "C:\Users\Administrator.DESKTOP-M4OGFT6\AppData\Roaming\Python\Python37\site packages\IPython\core\interactiveshell.py", line 3441, in run_code exec(code_obj, self.user_global_ns, self.user_ns)
File "
So I changed from pymatgen import Structure, Lattice
to from pymatgen.core import Structure, Lattice
in file structure.py
But there is still the following problem:
Traceback (most recent call last):
File "C:\Users\Administrator.DESKTOP-M4OGFT6\AppData\Roaming\Python\Python37\site packages\IPython\core\interactiveshell.py", line 3441, in run_code exec(code_obj, self.user_global_ns, self.user_ns)
File "
What can I do to correct my mistakes? Thank you very much !
From your information, it looks like there is a conflict between Pymatgen and matminer, as I alluded to in my original message.
You have two options:
pip uninstall pymatgen
followed by pip install pymatgen==2020.12.3
, for instance. Check the version number with import pymatgen as pm
followed by print(pm.__version__)
.
ORpip uninstall matminer
(confirm it's not installed anymore by trying to import matminer
) followed by git clone https://github.com/hackingmaterials/matminer.git
and using pip install .
(or pip install -r requirements.txt
) in the base directory. In my prior message, I walked through the steps on how to address Option 2. However, it looks like you did not properly uninstall your version of matminer to replace it with the most recent version on GitHub. This is most clearly seen in the following error message:
File "D:\ProgramData\Anaconda3\lib\site-packages\matminer\featurizers\structure.py", line 21, in from pymatgen import Structure, Lattice
ImportError: cannot import name 'Structure' from 'pymatgen' (unknown location)
The current version of matminer on GitHub already has the updated from pymatgen.core import Structure, Lattice
line, which means that you are not using this version of matminer despite using a version of Pymatgen that is >= 2022.0.*.
If you are still having issues after trying the above options, create a minimal Python script that only has the following to help with debugging:
from matminer.featurizers.structure import OrbitalFieldMatrix
If the above fails, I recommend opening an issue on the matminer page since it's a matminer-specific issue.
As you said, the above method successfully solved my problem.You're so brillian. Thank you very much for your help!
Glad to help!
Moved from https://github.com/arosen93/QMOF/discussions/16, which stated: _This is my prolem,ImportError: cannot import name 'VoronoiCoordFinder' from 'pymatgen.analysis.structureanalyzer'. What is the version of pymatgen package?Has the function been removed? How can I solve this problem? Thank you very much.
Hi @tuantuan-lin. I'm happy to try and help. Pymatgen recently introduced some backwards-incompatible changes with how functions are called, as noted here. I imagine this is the likely cause.
In order to help you, let's make sure we're talking about the same thing. I assume that you are referring to
ofm_feature_generator.py
, correct? And the problem appears upon calling theOrbitalFieldMatrix
function from matminer? Please let me know the full traceback error (e.g. what lines it's failing on).If this is the case, please try the following:
pip install pymatgen
).git clone https://github.com/hackingmaterials/matminer.git
).pip install .
As for the specific versions used in the QMOF Database paper, please see the "Additional Software and Hardware Details for Machine Learning" section (bottom of pg 8) in the Supporting Information. I used Pymatgen v.2020.12.3 with matminer v.0.6.4.