FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

TypeError: __init__() got an unexpected keyword argument 'package_name' · Issue #311 · python-kasa/python-kasa · GitHub

Repository navigation

TypeError: __init__() got an unexpected keyword argument 'package_name' #311

Closed

Description

Current git gives me this error:

Traceback (most recent call last):
File "c:\program files\python39\lib\runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "c:\program files\python39\lib\runpy.py", line 87, in run_code
exec(code, run_globals)
File "c:\Users\Matthew\AppData\Roaming\Python\Python39\Scripts\kasa.exe_main
.py", line 4, in
File "C:\Users\Matthew\AppData\Roaming\Python\Python39\site-packages\kasa\cli.py", line 61, in
async def cli(ctx, host, alias, target, debug, bulb, plug, lightstrip, strip, type):
File "C:\Users\Matthew\AppData\Roaming\Python\Python39\site-packages\asyncclick\decorators.py", line 304, in decorator
return option(*(param_decls or ("--version",)), **attrs)(f)
File "C:\Users\Matthew\AppData\Roaming\Python\Python39\site-packages\asyncclick\decorators.py", line 192, in decorator
_param_memo(f, OptionClass(param_decls, **option_attrs))
File "C:\Users\Matthew\AppData\Roaming\Python\Python39\site-packages\asyncclick\core.py", line 1750, in init
Parameter.init(self, param_decls, type=type, **attrs)
TypeError: init() got an unexpected keyword argument 'package_name'

I cloned the repo, ran "poetry install" and then "kasa discover". As per instructions.

Activity

  1. chaseroden commented on Feb 13, 2022

    I have this problem as well, on OS X using python3.9. The issue is not a previously-installed version of click/asyncclick as I'm installing in a fresh venv and never had it installed anyway. I was able to get it to work by reverting commit 6ece506, e.g.

    cd python-kasa
    git revert 6ece506a3bf3b76e1c6f3a9a11b93f47ceb9a3e6
    poetry install
    
  2. rytilahti commented on Feb 13, 2022

    Member

    Please update asyncclick to be version 8.0 or later, that will also fix it.

  3. memecode commented on Feb 14, 2022

    Author

    I tried that fix and now my "poetry install" command runs without error, but no kasa.exe is generated. I did have to "poetry update".

    Why would there by no binary built?

    This does actually run though:
    poetry run kasa discover

    However it doesn't discover anything... which I guess is another different bug.

  4. rytilahti commented on Feb 14, 2022

    Member

    poetry install creates a separate virtual environment so the command is installed inside that virtual environment. If you type poetry env info in the repository directory, it will show you the path inside of which the entry point is installed:

    ❯ poetry env info
    
    Virtualenv
    Python:         3.10.2
    Implementation: CPython
    Path:           /home/tpr/.cache/pypoetry/virtualenvs/python-kasa-TK6VvBHa-py3.10
    Valid:          True
    

    So in my case the script is in /home/tpr/.cache/pypoetry/virtualenvs/python-kasa-TK6VvBHa-py3.10/bin/kasa.

    You can either use poetry shell to activate the environment which adjusts the path so that executing kasa works directly, or use poetry run as you did.

    The discovery is indeed another problem, are you devices perhaps in a different network, or do you have multiple network interfaces? You can use --target to specify the network that is being used for discovery instead of the default broadcast address 255.255.255.255 like this:

    kasa --target 192.168.123.255 discover
    
  5. memecode commented on Feb 14, 2022

    Author

    You can either use poetry shell to activate the environment which adjusts the path so that executing kasa works directly, or use poetry run as you did.

    Ah that's the missing piece for me. Thanks for your very helpful reply.

    The discovery is indeed another problem, are you devices perhaps in a different network, or do you have multiple network interfaces? You can use --target to specify the network that is being used for discovery instead of the default broadcast address 255.255.255.255 like this:

    Right that makes some sense. When I run:

    kasa --target 192.168.0.255

    My devices show up. It's annoying that 255.255.255.255 doesn't work on my windows. Is there a way of getting kasa to remember the interface to target? So I don't have to tell it via the cmd line every time.

    FYI I also get a bunch of this after the list of devices:

    Exception ignored in: <function _ProactorBasePipeTransport.del at 0x00000175E0EE6280>
    Traceback (most recent call last):
    File "c:\program files\python39\lib\asyncio\proactor_events.py", line 116, in del
    self.close()
    File "c:\program files\python39\lib\asyncio\proactor_events.py", line 108, in close
    self._loop.call_soon(self._call_connection_lost, None)
    File "c:\program files\python39\lib\asyncio\base_events.py", line 746, in call_soon
    self._check_closed()
    File "c:\program files\python39\lib\asyncio\base_events.py", line 510, in _check_closed
    raise RuntimeError('Event loop is closed')
    RuntimeError: Event loop is closed

  6. rytilahti commented on Feb 14, 2022

    Member

    @memecode You're welcome! :-) I created a PR to allow defining KASA_TARGET environment variable that you could use on windows. Please create a separate issue for the event loop issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL