Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
xiaowangfeng opened this issue Feb 27, 2024 · 6 comments
Open

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

xiaowangfeng opened this issue Feb 27, 2024 · 6 comments

Comments

@xiaowangfeng
Copy link

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

@ml-evs
Copy link
Contributor

ml-evs commented Feb 27, 2024

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
Copy link
Author

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
Copy link
Member

JaGeo commented Feb 27, 2024

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
Copy link
Author

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
Copy link
Author

Once again, I'm sorry for my behavior

@JaGeo
Copy link
Member

JaGeo commented Feb 27, 2024

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. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants