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

ImportError: cannot import name 'SymmetryGroup' from partially initialized module 'pymatgen.symmetry.groups' #4309

Open
janosh opened this issue Mar 1, 2025 · 1 comment
Labels

Comments

@janosh
Copy link
Member

janosh commented Mar 1, 2025

Python version

3.13

Pymatgen version

2025.2.18

Operating system version

macOS

Current behavior

from pymatgen.symmetry.groups import SpaceGroup
  File "/opt/hostedtoolcache/Python/3.11.11/x64/lib/python3.11/site-packages/pymatgen/symmetry/groups.py", line 21, in <module>
    from pymatgen.core.operations import SymmOp
  File "/opt/hostedtoolcache/Python/3.11.11/x64/lib/python3.11/site-packages/pymatgen/core/__init__.py", line 17, in <module>
    from pymatgen.core.structure import IMolecule, IStructure, Molecule, PeriodicNeighbor, SiteCollection, Structure
  File "/opt/hostedtoolcache/Python/3.11.11/x64/lib/python3.11/site-packages/pymatgen/core/structure.py", line 44, in <module>
    from pymatgen.symmetry.maggroups import MagneticSpaceGroup
  File "/opt/hostedtoolcache/Python/3.11.11/x64/lib/python3.11/site-packages/pymatgen/symmetry/maggroups.py", line 17, in <module>
    from pymatgen.symmetry.groups import SymmetryGroup, in_array_list
ImportError: cannot import name 'SymmetryGroup' from partially initialized module 'pymatgen.symmetry.groups' (most likely due to a circular import) (/opt/hostedtoolcache/Python/3.11.11/x64/lib/python3.11/site-packages/pymatgen/symmetry/groups.py)

Expected Behavior

this same error showed up twice before in 2022 and 2023

worth adding a unit test to catch this so that it doesn't slip through a 4th time

Minimal example

from pymatgen.symmetry.groups import SpaceGroup

Relevant files to reproduce this bug

showed up in janosh/pymatviz#275

@janosh janosh added the bug label Mar 1, 2025
@janosh
Copy link
Member Author

janosh commented Mar 1, 2025

depending on use case, viable workaround may be to use from moyopy import SpaceGroupType instead

janosh added a commit to janosh/pymatviz that referenced this issue Mar 1, 2025
janosh added a commit to janosh/pymatviz that referenced this issue Mar 1, 2025
materialsproject/pymatgen#4309

examples/matbench_perovskites_eda.ipynb remove ipynb cell output with huge line count
janosh added a commit to janosh/pymatviz that referenced this issue Mar 1, 2025
materialsproject/pymatgen#4309

examples/matbench_perovskites_eda.ipynb remove ipynb cell output with huge line count
janosh added a commit to janosh/pymatviz that referenced this issue Mar 1, 2025
materialsproject/pymatgen#4309

examples/matbench_perovskites_eda.ipynb remove ipynb cell output with huge line count
janosh added a commit to janosh/pymatviz that referenced this issue Mar 1, 2025
* remove `get_cbar_label_formatter()` from `utils/plotting.py`

- Remove corresponding import and test cases

* import `calculate_rdf` in RDF module's `__init__.py`

- Update test case in `test_both_powerups.py` to use `add_scatter` instead of `add_trace`
- Minor SVG asset updates for element pair RDFs

* swap spglib for moyopy in example notebooks

plus minor refactors

* more spglib for moyopy swapping

- Update structure visualization scripts to use moyopy for space group number retrieval
- Modify spacegroup_sunburst and spacegroup_bar to work with moyopy
- Add mapping for Hermann-Maguin short symbols to space group numbers
- Remove commented-out SVG saving in sunburst script

* fix pymatgen SpaceGroup circular import error

materialsproject/pymatgen#4309

examples/matbench_perovskites_eda.ipynb remove ipynb cell output with huge line count

* breaking: rename `crystal_sys_from_spg_num()` to `spg_to_crystal_sys()`

- now also supports converting space group symbols to crystal systems, not just numbers
- Create `spg_num_to_from_symbol()` for bidirectional space group number/symbol conversion
- bump moyopy to 0.4.1
- Modify scripts to use new utility functions across various dataset exploration examples
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant