/import_logs.py not working with python 3.9

Hello !
I migrated my matomo to a new server with python 3.9. I cannot import anymore the logs when it was working fine with python 3.7

python3 mymatomopath/httpdocs//misc/log-analytics/import_logs.py --url=https://mymatomo.com/ --idsite=48 --recorders=4 --enable-http-errors --enable-http-redirects --enable-static --enable-bots var/log//apache2/myweb48.com/access_log.processed

result is

Traceback (most recent call last):
  File "mymatomopath/httpdocs//misc/log-analytics/import_logs.py", line 1588, in _call_api
    return json.loads(res)
  File "/usr/lib/python3.9/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3.9/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.9/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "mymatomopath/httpdocs//misc/log-analytics/import_logs.py", line 2688, in <module>
    resolver = config.get_resolver()
  File "mymatomopath/httpdocs//misc/log-analytics/import_logs.py", line 1131, in get_resolver
    return StaticResolver(self.options.site_id)
  File "mymatomopath/httpdocs//misc/log-analytics/import_logs.py", line 1663, in __init__
    site = matomo.call_api(
  File "mymatomopath/httpdocs//misc/log-analytics/import_logs.py", line 1647, in call_api
    return self._call_wrapper(self._call_api, None, None, method, **kwargs)
  File "mymatomopath/httpdocs//misc/log-analytics/import_logs.py", line 1599, in _call_wrapper
    response = func(*args, **kwargs)
  File "mymatomopath/httpdocs//misc/log-analytics/import_logs.py", line 1590, in _call_api
    raise urllib.error.URLError('Matomo returned an invalid response: ' + res.decode("utf-8") )
AttributeError: 'str' object has no attribute 'decode'```

Any idea about this problem ?! Do I have to downgrade python ?

finally I compiled python 3.7.3 to get same version than older server. no luck, still same message (with /python3.7 path)
I guess that this is not really linked to python itself but I cannot find what is causing this issue.
the same command is running fine on older server. something is really strange here :frowning:


Are you sure it’s not a-url= problem ? I had exactly the same error, I was just pointing to the wrong url…
Same here : https://github.com/matomo-org/matomo-log-analytics/issues/344


Sorry, I know that I solved the problem but I completly forget to update this thread and now I do not remember how I solved it. But the URL was not the reason. :frowning: