Strange error in DensityFeatures import

I have been trying to go through the matminer-notes.ipynb example notebook from the 2020 workshop. Due to the recent change in convenience imports (e.g. from pymatgen import Element), it doesn’t work out of the box anymore, however, I have modified the import statements to avoid these errors. The example notebook. There are two errors that occur in the notebook (before automatminer which I have yet to install). I was hoping someone could help me out on how to fix these errors.

  1. In one of the first scikit-learn examples, the example with KFold fails with a nasty error message saying that setting random_state=1 makes not sense. Does it?

from sklearn.model_selection import KFold

kfold = KFold(n_splits=10, random_state=1)

  1. On attempting to import DensityFeatures from matminer, the following error (see below) occurs. It seems to related to getting path information from the os library. What is going on – and how can I fix it.

from matminer.featurizers.structure import DensityFeatures

densityf = DensityFeatures()
densityf.feature_labels()

TypeError Traceback (most recent call last)
in
----> 1 from matminer.featurizers.structure import DensityFeatures
2
3 densityf = DensityFeatures()
4 densityf.feature_labels()

/data/miniconda/envs/matminer/lib/python3.8/site-packages/matminer/featurizers/structure.py in
32
33 from matminer.featurizers.base import BaseFeaturizer
—> 34 from matminer.featurizers.site import OPSiteFingerprint,
35 CoordinationNumber, LocalPropertyDifference, CrystalNNFingerprint,
36 AverageBondAngle, AverageBondLength

/data/miniconda/envs/matminer/lib/python3.8/site-packages/matminer/featurizers/site.py in
63
64 cn_motif_op_params = {}
—> 65 with open(os.path.join(os.path.dirname(
66 pymatgen.analysis.file), ‘cn_opt_params.yaml’), ‘r’) as f:
67 cn_motif_op_params = yaml.safe_load(f)

/data/miniconda/envs/matminer/lib/python3.8/posixpath.py in dirname(p)
150 def dirname(p):
151 “”“Returns the directory component of a pathname”""
→ 152 p = os.fspath(p)
153 sep = _get_sep(p)
154 i = p.rfind(sep) + 1

TypeError: expected str, bytes or os.PathLike object, not NoneType

1 Like

Hi Paul Fons,
I am also getting the same error in Density Features module. Did you find any solution for this?

Hi @Ramanuja_Srinivasan did you install from conda? Or pypi? Or via github git clone?

I used “pip install matminer” command to install the matminer software package.

@Ramanuja_Srinivasan I will open an issue on the repo for this, see pip installs cannot import DensityFeatures · Issue #740 · hackingmaterials/matminer · GitHub

Note this should be resolved now with newest matminer on github, and should be ok in next release on pypi/conda