cduck / latextools

A collection of tools for building, rendering, and converting Latex documents
MIT License
22 stars 2 forks source link

AttributeError: partially initialized module 'latextools' has no attribute 'render_snippet' #2

Closed eidoom closed 2 years ago

eidoom commented 2 years ago

OS: Fedora 35 Python: 3.10

Attempting to run the first example yields

Traceback (most recent call last):
  File "/home/USER/scratch/latex2svg/latextools.py", line 1, in <module>
    import latextools
  File "/home/USER/scratch/latex2svg/latextools.py", line 4, in <module>
    latex_eq = latextools.render_snippet(
AttributeError: partially initialized module 'latextools' has no attribute 'render_snippet' (most likely due to a circular import)
cduck commented 2 years ago

Thanks for the bug report.

The issue here is a name conflict between your script latextools.py and the module latextools, not an issue with the package. When you write import latextools Python checks your current directory for .py files before checking for installed packages. This causes a circular import where your script imports itself, similar to this one.

Fix: rename your script to something other than latextools.py.

eidoom commented 2 years ago

Thank you for the very clear explanation!