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

[Bug]: 运行示例,提示urllib3库中没有get_host,请问这要怎么解决? #419

Open
Easen-L opened this issue Dec 15, 2023 · 5 comments

Comments

@Easen-L
Copy link

Easen-L commented Dec 15, 2023

Environment

- wechaty:0.10.7
- wechaty-puppet: 0.4.23
- wechaty-puppet-service: 0.8.10
- wechaty-plugin-contrib: 0.0.25
- token type: padlocal|wxwork|xp
- the version of wechaty docker container: [0.65]

Description

"E:\A software\python\Python311\python.exe" "E:/Total Project/python project/order_automatic_push/python-wechaty-main/examples/contact-bot.py"
Traceback (most recent call last):
  File "E:\Total Project\python project\order_automatic_push\python-wechaty-main\examples\contact-bot.py", line 8, in <module>
    from wechaty import Wechaty, Contact
  File "E:\A software\python\Python311\Lib\site-packages\wechaty\__init__.py", line 54, in <module>
    from .wechaty import (
  File "E:\A software\python\Python311\Lib\site-packages\wechaty\wechaty.py", line 72, in <module>
    from wechaty.user.url_link import UrlLink
  File "E:\A software\python\Python311\Lib\site-packages\wechaty\user\__init__.py", line 8, in <module>
    from .message         import Message
  File "E:\A software\python\Python311\Lib\site-packages\wechaty\user\message.py", line 51, in <module>
    from .url_link import UrlLink
  File "E:\A software\python\Python311\Lib\site-packages\wechaty\user\url_link.py", line 10, in <module>
    from urllib3 import get_host
ImportError: cannot import name 'get_host' from 'urllib3' (E:\A software\python\Python311\Lib\site-packages\urllib3\__init__.py)

Minimum reproducible code

Snipaste_2023-12-15_14-19-03
@Easen-L Easen-L changed the title [Bug]: 运行示例,提示urllib3库中没有get_host,这get_hos是干嘛用?怎么解决? [Bug]: 运行示例,提示urllib3库中没有get_host,请问这要怎么解决? Dec 15, 2023
@kehuanjack
Copy link

You can try to reduce its version to below 2.0. Use command like pip install "urllib3<2.0.0".

@Easen-L
Copy link
Author

Easen-L commented Dec 19, 2023

Understood, thank you

@AurganicSubstance
Copy link

I tried lowering the version, got new problem:
Traceback (most recent call last):
File "D:\QWEN\main.py", line 31, in
from wechaty import Wechaty
File "D:\QWEN\venv\Lib\site-packages\wechaty_init_.py", line 54, in
from .wechaty import (
File "D:\QWEN\venv\Lib\site-packages\wechaty\wechaty.py", line 111, in
@DataClass
^^^^^^^^^
File "C:\Users\Writer's Cave\AppData\Local\Programs\Python\Python311\Lib\dataclasses.py", line 1220, in dataclass
return wrap(cls)
^^^^^^^^^
File "C:\Users\Writer's Cave\AppData\Local\Programs\Python\Python311\Lib\dataclasses.py", line 1210, in wrap
return _process_class(cls, init, repr, eq, order, unsafe_hash,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Writer's Cave\AppData\Local\Programs\Python\Python311\Lib\dataclasses.py", line 958, in _process_class
cls_fields.append(_get_field(cls, name, type, kw_only))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Writer's Cave\AppData\Local\Programs\Python\Python311\Lib\dataclasses.py", line 815, in _get_field
raise ValueError(f'mutable default {type(f.default)} for field '
ValueError: mutable default <class 'wechaty_puppet.schemas.puppet.PuppetOptions'> for field puppet_options is not allowed: use default_factory

@suwjwj
Copy link

suwjwj commented Jan 21, 2024

为 urllib3 添加 get_host 函数

from urllib.parse import urlparse
def get_host(url: str) -> (str, str, str):
parsed_url = urlparse(url)
return parsed_url.scheme, parsed_url.netloc, parsed_url.path
import urllib3
urllib3.get_host = get_host

@yiwilee
Copy link

yiwilee commented May 17, 2024

I tried lowering the version, got new problem: Traceback (most recent call last): File "D:\QWEN\main.py", line 31, in from wechaty import Wechaty File "D:\QWEN\venv\Lib\site-packages\wechaty__init__.py", line 54, in from .wechaty import ( File "D:\QWEN\venv\Lib\site-packages\wechaty\wechaty.py", line 111, in @DataClass ^^^^^^^^^ File "C:\Users\Writer's Cave\AppData\Local\Programs\Python\Python311\Lib\dataclasses.py", line 1220, in dataclass return wrap(cls) ^^^^^^^^^ File "C:\Users\Writer's Cave\AppData\Local\Programs\Python\Python311\Lib\dataclasses.py", line 1210, in wrap return _process_class(cls, init, repr, eq, order, unsafe_hash, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Writer's Cave\AppData\Local\Programs\Python\Python311\Lib\dataclasses.py", line 958, in _process_class cls_fields.append(_get_field(cls, name, type, kw_only)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Writer's Cave\AppData\Local\Programs\Python\Python311\Lib\dataclasses.py", line 815, in _get_field raise ValueError(f'mutable default {type(f.default)} for field ' ValueError: mutable default <class 'wechaty_puppet.schemas.puppet.PuppetOptions'> for field puppet_options is not allowed: use default_factory

Can you fix it?

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

5 participants