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

Is asyncclick can't use in windows? #8

Closed
ShirleyChau opened this issue Sep 24, 2020 · 9 comments
Closed

Is asyncclick can't use in windows? #8

ShirleyChau opened this issue Sep 24, 2020 · 9 comments

Comments

@ShirleyChau
Copy link

When I used it in windows,I got an error that: _wrap_std_stream' from 'asyncclick._winconsole
But when I used it in wsl,it was available.
All error info :
(aerichtest-Io3kg-ro-py3.8) C:\Users\surface\PycharmProjects\aerichTest>aerich init -h Traceback (most recent call last): File "C:\Users\surface\AppData\Local\pypoetry\Cache\virtualenvs\aerichtest-Io3kg-ro- py3.8\Scripts\aerich-script.py", line 11, in <module> load_entry_point('aerich', 'console_scripts', 'aerich')() File "c:\users\surface\appdata\local\pypoetry\cache\virtualenvs\aerichtest-io3kg-ro- py3.8\lib\site-packages\pkg_resources\__init__.py", line 490, in load_entry_point return get_distribution(dist).load_entry_point(group, name) File "c:\users\surface\appdata\local\pypoetry\cache\virtualenvs\aerichtest-io3kg-ro- py3.8\lib\site-packages\pkg_resources\__init__.py", line 2862, in load_entry_point return ep.load() File "c:\users\surface\appdata\local\pypoetry\cache\virtualenvs\aerichtest-io3kg-ro- py3.8\lib\site-packages\pkg_resources\__init__.py", line 2462, in load return self.resolve() File "c:\users\surface\appdata\local\pypoetry\cache\virtualenvs\aerichtest-io3kg-ro- py3.8\lib\site-packages\pkg_resources\__init__.py", line 2468, in resolve module = __import__(self.module_name, fromlist=['__name__'], level=0) File "c:\users\surface\appdata\local\pypoetry\cache\virtualenvs\aerichtest-io3kg-ro- py3.8\src\aerich\aerich\cli.py", line 8, in <module> import asyncclick as click File "c:\users\surface\appdata\local\pypoetry\cache\virtualenvs\aerichtest-io3kg-ro- py3.8\lib\site-packages\asyncclick\__init__.py", line 7, in <module> from .core import Argument File "c:\users\surface\appdata\local\pypoetry\cache\virtualenvs\aerichtest-io3kg-ro-py3.8\lib\site-packages\asyncclick\core.py", line 18, in <module> from ._compat import isidentifier File "c:\users\surface\appdata\local\pypoetry\cache\virtualenvs\aerichtest-io3kg-ro-py3.8\lib\site-packages\asyncclick\_compat.py", line 540, in <module> from ._winconsole import _get_windows_console_stream, _wrap_std_stream ImportError: cannot import name '_wrap_std_stream' from 'asyncclick._winconsole' (c:\users\surface\appdata\local\pypoetry\cache\virtualenvs\aerichtest-io3kg-ro-py3.8\lib\site-packa ges\asyncclick\_winconsole.py)

Environment

  • Python version:3.8
  • Click version:7.1.2.1
@gimebreak
Copy link

I also have the same issue

@ShirleyChau
Copy link
Author

ShirleyChau commented Sep 28, 2020

Now I use the other method:
I create a Decorator
`

def open_db(func):
async def open_db_inner(*args, **kwargs):
result = await func(*args, **kwargs)
await Tortoise.close_connections()
return result
@functools.wraps(func)
def close_db_inner2(*args, **kwargs):
return asyncio.run(close_db_inner(*args, **kwargs))
return close_db_inner2

`

@auphofBSF
Copy link

auphofBSF commented Oct 10, 2020

I am encountering same issue: (Windows) Please reopen this issue !

Python 3.7.6 | packaged by conda-forge | (default, Jun 1 2020, 18:11:50) [MSC v.1916 64 bit (AMD64)] on win32

import anyio
import asyncclick as click

@click.command()
@click.option("--count", default=1, help="Number of greetings.")
@click.option("--name", prompt="Your name", help="The person to greet.")
async def hello(count, name):
    """Simple program that greets NAME for a total of COUNT times."""
    for x in range(count):
        if x: await anyio.sleep(0.1)
        click.echo(f"Hello, {name}!")

if __name__ == '__main__':
    hello(_anyio_backend="asyncio")  # or asyncio, or curio
Traceback (most recent call last):
  File ".\Example_asyncclick.py", line 2, in <module>
    import asyncclick as click
  File "C:\Users\<USER>\Anaconda3\envs\<ENV>\lib\site-packages\asyncclick\__init__.py", line 7, in <module>
    from .core import Argument
  File "C:\Users\<USER>\Anaconda3\envs\<ENV>\\lib\site-packages\asyncclick\core.py", line 18, in <module>
    from ._compat import isidentifier
  File "C:\Users\<USER>\Anaconda3\envs\<ENV>\\lib\site-packages\asyncclick\_compat.py", line 540, in <module>
    from ._winconsole import _get_windows_console_stream, _wrap_std_stream
ImportError: cannot import name '_wrap_std_stream' from 'asyncclick._winconsole' (C:\Users\<USER>\Anaconda3\envs\<ENV>\\lib\site-packages\asyncclick\_winconsole.py)

When I down grade to pip install asyncclick==7.0.9 (as mentioned in python-kasa/python-kasa#106) Then all works OK !

@smurfix smurfix reopened this Oct 10, 2020
@smurfix
Copy link
Collaborator

smurfix commented Oct 10, 2020

Does non-async-click work?

@auphofBSF
Copy link

Yes

@smurfix
Copy link
Collaborator

smurfix commented Oct 10, 2020

Owch. Will look into it.

@smurfix
Copy link
Collaborator

smurfix commented Oct 10, 2020

Unused import. Please check whether the current master fixes this.

@auphofBSF
Copy link

SUCCESS, thank you
uninstalled 7.09, cloned master d18b28e and did pip install -e . and all working well 🙏

@smurfix
Copy link
Collaborator

smurfix commented Oct 10, 2020

Great. Uploaded 7.1.2.2 to pypi.

@smurfix smurfix closed this as completed Oct 10, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants