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

InvalidVersion on importing ytmusicapi #1336

Closed
khmikkelsen opened this issue Aug 21, 2021 · 6 comments
Closed

InvalidVersion on importing ytmusicapi #1336

khmikkelsen opened this issue Aug 21, 2021 · 6 comments

Comments

@khmikkelsen
Copy link

khmikkelsen commented Aug 21, 2021

AppDaemon version: 4.1.0
HA: Supervisor 6.2 & core-2021.8.8

Importing ytmusicapi will throw InvalidVersion, possibly related to pkg_resources. My config:

system_packages:
  - libffi
  - py3-setuptools
python_packages:
  - ytmusicapi
init_commands: []

And the resulting error log:

2021-08-22 01:26:42.588304 WARNING Error: ------------------------------------------------------------
2021-08-22 01:26:42.587155 WARNING Error: Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/packaging/version.py", line 57, in parse
    return Version(version)
  File "/usr/lib/python3.9/site-packages/packaging/version.py", line 298, in __init__
    raise InvalidVersion("Invalid version: '{0}'".format(version))
packaging.version.InvalidVersion: Invalid version: '/usr/lib/python3.9/site'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/appdaemon/app_management.py", line 970, in check_app_updates
    await utils.run_in_executor(self, self.read_app, mod["name"], mod["reload"])
  File "/usr/lib/python3.9/site-packages/appdaemon/utils.py", line 308, in run_in_executor
    response = future.result()
  File "/usr/lib/python3.9/concurrent/futures/thread.py", line 52, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/lib/python3.9/site-packages/appdaemon/app_management.py", line 747, in read_app
    importlib.reload(self.modules[module_name])
  File "/usr/lib/python3.9/importlib/__init__.py", line 169, in reload
    _bootstrap._exec(spec, module)
  File "", line 613, in _exec
  File "", line 855, in exec_module
  File "", line 228, in _call_with_frames_removed
  File "/config/appdaemon/apps/music_flow.py", line 7, in 
    from ytmusicapi import YTMusic
  File "/usr/lib/python3.9/site-packages/ytmusicapi/__init__.py", line 2, in 
    from ytmusicapi.ytmusic import YTMusic
  File "/usr/lib/python3.9/site-packages/ytmusicapi/ytmusic.py", line 3, in 
    import pkg_resources
  File "/usr/lib/python3.9/site-packages/pkg_resources/__init__.py", line 3243, in 
    def _initialize_master_working_set():
  File "/usr/lib/python3.9/site-packages/pkg_resources/__init__.py", line 3226, in _call_aside
    f(*args, **kwargs)
  File "/usr/lib/python3.9/site-packages/pkg_resources/__init__.py", line 3255, in _initialize_master_working_set
    working_set = WorkingSet._build_master()
  File "/usr/lib/python3.9/site-packages/pkg_resources/__init__.py", line 559, in _build_master
    ws = cls()
  File "/usr/lib/python3.9/site-packages/pkg_resources/__init__.py", line 552, in __init__
    self.add_entry(entry)
  File "/usr/lib/python3.9/site-packages/pkg_resources/__init__.py", line 608, in add_entry
    for dist in find_distributions(entry, True):
  File "/usr/lib/python3.9/site-packages/pkg_resources/__init__.py", line 2059, in find_on_path
    path_item_entries = _by_version_descending(filtered)
  File "/usr/lib/python3.9/site-packages/pkg_resources/__init__.py", line 2029, in _by_version_descending
    return sorted(names, key=_by_version, reverse=True)
  File "/usr/lib/python3.9/site-packages/pkg_resources/__init__.py", line 2027, in _by_version
    return [packaging.version.parse(part) for part in parts]
  File "/usr/lib/python3.9/site-packages/pkg_resources/__init__.py", line 2027, in 
    return [packaging.version.parse(part) for part in parts]
  File "/usr/lib/python3.9/site-packages/packaging/version.py", line 59, in parse
    return LegacyVersion(version)
  File "/usr/lib/python3.9/site-packages/packaging/version.py", line 127, in __init__
    warnings.warn(
DeprecationWarning: Creating a LegacyVersion has been deprecated and will be removed in the next major release
@ReneTode
Copy link
Contributor

importing "hi-I-am-busy"
will also throw an error.

bu why would it be a problem from the AD addon (not even AD itself) that some unrelated packages (lib) isnt installable without extra efford??

@khmikkelsen
Copy link
Author

khmikkelsen commented Aug 22, 2021

I havn't been able to find references to other packages causing the same problem for AD, also this error did not only occur on python 3.9, as I had the same error on AD 4.0.8. I've only encountered this error for ytmusic api in the context of AD, which is why I took it up here first.

I'll take up the issue on the ytmusic api page instead, or perhaps pkg_resources..

@frenck
Copy link
Contributor

frenck commented Aug 22, 2021

The add-on that had AD 4.0.8 was not running Python 3.9...

@khmikkelsen
Copy link
Author

I see.. It was just the add-on not running 3.9.

@khmikkelsen
Copy link
Author

khmikkelsen commented Aug 22, 2021

I found the actual issue... wheel had to be installed with system-packages.

edit: not the actual issue, but it was another issue even after forking ytmusicapi and replacing pkg_resources with importlib_resources.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants