materialsproject / api

New API client for the Materials Project
https://materialsproject.github.io/api/
Other
108 stars 40 forks source link

ModuleNotFoundError: No module named 'pymatgen.plotting' #891

Open xiaowangfeng opened 7 months ago

xiaowangfeng commented 7 months ago

how to solve the question, I want to visualize .cif file.

ml-evs commented 7 months ago

Please post the entire error message and traceback, including the code you are trying to run. It is impossible to answer your question otherwise.

This package never tries to import pymatgen.plotting (which I'm pretty sure does not exist anyway) so it must be some other code that is triggering it.

xiaowangfeng commented 7 months ago

from pymatgen.io.cif import CifParser from pymatgen.plotting import BSPlotter import matplotlib.pyplot as plt

读取 CIF 文件

parser = CifParser("mp-6127.cif") structure = parser.get_structures()[0]

可选:如果你想调整晶体结构到原胞,可以使用 SpacegroupAnalyzer

analyzer = SpacegroupAnalyzer(structure) structure = analyzer.get_primitive_standard_structure()

使用 BSPlotter 可视化晶体结构

plotter = BSPlotter(structure) plotter.show()

如果你想将可视化结果保存为图像文件,你也可以使用 Matplotlib

plt.savefig("structure.png")

that‘s all. please tell how to improve it thanks

JaGeo commented 7 months ago

Dear @xiaowangfeng ,

It feels like a lot of code is actually missing to do the required tasks. There are tutorials around the MP that you might find helpful: https://youtube.com/playlist?list=PLTjFYVNE7LTi6kGvPAF7DDQYj0KDL-vQL&si=w8y5_SacASkgo9pG

Or use the matsci Forum for further help: https://matsci.org

In general, your requests need to be much more specific, also for the forum. Here, the issues are meant for actual software bugs, not general help requests.

I hope you can understand this.

xiaowangfeng commented 7 months ago

Sorry, I am a novice to materials chemistry. I downloaded some data through materials project and wanted to realize the visualization of.cif through pymatgen, but the code kept giving errors. In desperation, I want to ask for help through here, thank you

xiaowangfeng commented 7 months ago

Once again, I'm sorry for my behavior

JaGeo commented 7 months ago

I very well understand this. This is why I am pointing to the tutorials that have been made for the purpose and the forum that can be used to ask questions. :)