question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Fonts not working: TypeError: expected string or bytes-like object

See original GitHub issue

Worked perfectly through all other updates and betas. Beta 2021.2 is the only version that’s had problems with roborock camera. Python 3.7 was removed? Not sure if that has an effect. Here’s the log:

Logger: homeassistant.helpers.entity
Source: custom_components/xiaomi_cloud_map_extractor/image_handler.py:236
First occurred: 10:35:20 PM (9 occurrences)
Last logged: 10:36:32 PM
Update for camera.roborock_camera fails
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 278, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 474, in async_device_update
    raise exc
  File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/xiaomi_cloud_map_extractor/camera.py", line 200, in update
    map_data = self._connector.get_map(self._country, map_name, self._colors, self._drawables, self._texts,
  File "/config/custom_components/xiaomi_cloud_map_extractor/xiaomi_cloud_connector.py", line 134, in get_map
    map_data = MapDataParser.parse(unzipped, colors, drawables, texts, sizes, image_config)
  File "/config/custom_components/xiaomi_cloud_map_extractor/map_data_parser.py", line 81, in parse
    ImageHandler.draw_texts(map_data.image, texts)
  File "/config/custom_components/xiaomi_cloud_map_extractor/image_handler.py", line 193, in draw_texts
    ImageHandler.__draw_text__(image, text_config[CONF_TEXT], x, y, text_config[CONF_COLOR],
  File "/config/custom_components/xiaomi_cloud_map_extractor/image_handler.py", line 245, in __draw_text__
    ImageHandler.__draw_on_new_layer__(image, draw_func)
  File "/config/custom_components/xiaomi_cloud_map_extractor/image_handler.py", line 259, in __draw_on_new_layer__
    draw_function(draw)
  File "/config/custom_components/xiaomi_cloud_map_extractor/image_handler.py", line 236, in draw_func
    font = ImageFont.truetype(font_file, font_size)
  File "/usr/local/lib/python3.8/site-packages/PIL/ImageFont.py", line 852, in truetype
    return freetype(font)
  File "/usr/local/lib/python3.8/site-packages/PIL/ImageFont.py", line 849, in freetype
    return FreeTypeFont(font, size, index, encoding, layout_engine)
  File "/usr/local/lib/python3.8/site-packages/PIL/ImageFont.py", line 173, in __init__
    freetype_version = parse_version(features.version_module("freetype2"))
  File "/usr/local/lib/python3.8/site-packages/packaging/version.py", line 57, in parse
    return Version(version)
  File "/usr/local/lib/python3.8/site-packages/packaging/version.py", line 296, in __init__
    match = self._regex.search(version)
TypeError: expected string or bytes-like object

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
jscherrycommented, Jan 28, 2021

Can you please close this. I had been using a full config and changed to suggested config after seeing your reply and it fixed it. Thanks

0reactions
vashilovcommented, Jul 28, 2021

Why if I add font: "NotoSans-BoldItalic.ttf" in config, addon crash? But if I change def __draw_text__(image: ImageData, text, x, y, color, font_file=None, font_size=None): font_file = "NotoSans-BoldItalic.ttf" font_size = 50 in /config/custom_components/xiaomi_cloud_map_extractor/common/image_handler.py, addon ok.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Fix: Typeerror: expected string or bytes-like object
This error typically occurs when you attempt to use the re.sub() function to replace certain patterns in an object but the object you're...
Read more >
Python-django typeerror: expected string or bytes-like object ...
It indicates that your field for your datetime (when you created an Author object with timezone.now ) was invalid. This is because you...
Read more >
TypeError expected string or bytes-like object - STechies
This error is encountered as there a couple of values in the code that are floats. In order to run the code successfully,...
Read more >
PIL在win10中引用字体文件时报错TypeError: expected string ...
主要错误:ImageFont.truetype引用字体文件报错TypeError: expected string or bytes-like object ; >pip install pillow Requirement already satisfied: ...
Read more >
3.10b2 -> 3.10b3 regression in importlib.metadata for rinoh
... line 187, in sub return _compile(pattern, flags).sub(repl, string, count) TypeError: expected string or bytes-like object ```.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found