mozman / ezdxf

Python interface to DXF
https://ezdxf.mozman.at
MIT License
938 stars 191 forks source link

'import ezdxf' fails #969

Closed JohnCC330 closed 1 year ago

JohnCC330 commented 1 year ago

Describe the bug Simply 'import ezdxf' produces errors To Reproduce In my case, executing this mini program is sufficient:

import ezdxf

ezdxf is version 1.1.2 (the version available in pypi). Here's the complete error message:

Traceback (most recent call last):
  File "/usr/local/projects/rf/linsmith1_meson/test_ezdxf.py", line 25, in <module>
    import ezdxf
  File "/usr/lib64/python3.9/site-packages/ezdxf/__init__.py", line 36, in <module>
    from ezdxf.filemanagement import readzip, new, read, readfile, decode_base64
  File "/usr/lib64/python3.9/site-packages/ezdxf/filemanagement.py", line 10, in <module>
    from ezdxf.tools.standards import setup_drawing
  File "/usr/lib64/python3.9/site-packages/ezdxf/tools/standards.py", line 8, in <module>
    from ezdxf.render.arrows import ARROWS
  File "/usr/lib64/python3.9/site-packages/ezdxf/render/__init__.py", line 20, in <module>
    from .mleader import (
  File "/usr/lib64/python3.9/site-packages/ezdxf/render/mleader.py", line 39, in <module>
    from ezdxf.tools import text_size, text as text_tools
  File "/usr/lib64/python3.9/site-packages/ezdxf/tools/text_size.py", line 9, in <module>
    from ezdxf.fonts import fonts
  File "/usr/lib64/python3.9/site-packages/ezdxf/fonts/fonts.py", line 733, in <module>
    _load_font_manager()
  File "/usr/lib64/python3.9/site-packages/ezdxf/fonts/fonts.py", line 286, in _load_font_manager
    build_font_manager_cache(fm_path)
  File "/usr/lib64/python3.9/site-packages/ezdxf/fonts/fonts.py", line 326, in build_font_manager_cache
    font_manager.build()
  File "/usr/lib64/python3.9/site-packages/ezdxf/fonts/font_manager.py", line 409, in build
    self.scan_all(dirs + list(options.support_dirs))
  File "/usr/lib64/python3.9/site-packages/ezdxf/fonts/font_manager.py", line 417, in scan_all
    self.scan_folder(Path(folder).expanduser())
  File "/usr/lib64/python3.9/site-packages/ezdxf/fonts/font_manager.py", line 427, in scan_folder
    self.scan_folder(file)
  File "/usr/lib64/python3.9/site-packages/ezdxf/fonts/font_manager.py", line 431, in scan_folder
    font_face = get_ttf_font_face(file)
  File "/usr/lib64/python3.9/site-packages/ezdxf/fonts/font_manager.py", line 452, in get_ttf_font_face
    ttf = TTFont(font_path, fontNumber=0)
  File "/usr/lib64/python3.9/site-packages/fontTools/ttLib/ttFont.py", line 175, in __init__
    self.reader = SFNTReader(file, checkChecksums, fontNumber=fontNumber)
  File "/usr/lib64/python3.9/site-packages/fontTools/ttLib/sfnt.py", line 85, in __init__
    raise TTLibError("Not a TrueType or OpenType font (bad sfntVersion)")
fontTools.ttLib.TTLibError: Not a TrueType or OpenType font (bad sfntVersion)

Python is 3.9.16 if that matters. I'm using Slackware64 15.0, used pip to install ezdxf. fonttools is version 4.44.3

mozman commented 1 year ago

You have to install the current beta version v1.1.3b1 to fix the issue.

JohnCC330 commented 1 year ago

Hi mozman. Thanks! Unfortunately, I get the same result

JohnCC330 commented 1 year ago

Digging a bit deeper, though I did a pip3 uninstall ezdxf, the version in site-packages is still 1.1.2. Do I have to python3 setup.py install --force?

kakasearch commented 1 year ago

I ran into the same problem, because /windows/fonts/mstmc.ttf file is corrupt, This can be solved by running the following code in terminal: cd /windows/fonts del mstmc.ttf

mozman commented 1 year ago

Install the beta version by:

pip install -U ezdxf==1.1.3b1

or

python3 -m pip install -U ezdxf==1.1.3b1

on Windows should also work

py -m pip install -U ezdxf==1.1.3b1
JohnCC330 commented 1 year ago

@mozman Thanks again!

I didn't find any reference about the 1.1.3b1 being on Pypi, so I finally could compile the tar.gz and managed to install it. For some reason, 1.1.3b1 wouldn't install with 1.1.2 still installed, and pip3 wouldn't remove 1.1.2. I removed it by hand, and then ./setup install for 1.1.3b1 worked.

I could now import ezdxf. I opened an uncompressed 11 MB dxf and it seemed rather slow (12 seconds)

mozman commented 1 year ago

@JohnCC330 Beta versions are hidden on PyPI 😊

image

image

JohnCC330 commented 1 year ago

Ah well... And I thought that 'History' meant 'past events' not future ones ;-)