wechaty / python-wechaty

Python Wechaty is a Conversational RPA SDK for Chatbot Makers written in Python
https://wechaty.readthedocs.io/zh_CN/latest/
Apache License 2.0
1.62k stars 234 forks source link

[Bug]: 'NoneType' object has no attribute 'encode' #397

Open SOl0QQ opened 1 year ago

SOl0QQ commented 1 year ago

Environment

wechaty                0.10.7
wechaty-grpc           0.20.19
wechaty-puppet         0.4.23
wechaty-puppet-service 0.8.10

- wechaty-plugin-contrib: None
- the version of wechaty docker container: [latest]

WECHATY_PUPPET="wechaty-puppet-wechat4u"
WECHATY_TOKEN="python-wechaty-{uuid}"  the uuid is generated by  "uuid.uuid4()"

Description

An error occurred in the operation of the program:

2023-05-13 22:49:12,080 - Wechaty - INFO - init_puppet_event_bridge() <<wechaty_puppet_service.puppet.PuppetService object at 0x7f625e3c8898>>
2023-05-13 22:49:12,080 - Wechaty - INFO - initPuppetEventBridge() puppet.on(dong) (listenerCount:1) registering...
2023-05-13 22:49:12,080 - Wechaty - INFO - initPuppetEventBridge() puppet.on(error) (listenerCount:1) registering...
2023-05-13 22:49:12,080 - Wechaty - INFO - initPuppetEventBridge() puppet.on(heart-beat) (listenerCount:1) registering...
2023-05-13 22:49:12,080 - Wechaty - INFO - initPuppetEventBridge() puppet.on(ready) (listenerCount:1) registering...
2023-05-13 22:49:12,080 - Wechaty - INFO - receive <reset> event <%s>
2023-05-13 22:49:12,080 - Wechaty - INFO - initPuppetEventBridge() puppet.on(reset) (listenerCount:0) registering...
2023-05-13 22:49:12,081 - Wechaty - INFO - initPuppetEventBridge() puppet.on(friendship) (listenerCount:1) registering...
2023-05-13 22:49:12,081 - Wechaty - INFO - initPuppetEventBridge() puppet.on(login) (listenerCount:1) registering...
2023-05-13 22:49:12,081 - Wechaty - INFO - initPuppetEventBridge() puppet.on(logout) (listenerCount:1) registering...
2023-05-13 22:49:12,081 - Wechaty - INFO - initPuppetEventBridge() puppet.on(message) (listenerCount:1) registering...
2023-05-13 22:49:12,081 - Wechaty - INFO - initPuppetEventBridge() puppet.on(room-invite) (listenerCount:1) registering...
2023-05-13 22:49:12,081 - Wechaty - INFO - initPuppetEventBridge() puppet.on(room-join) (listenerCount:1) registering...
2023-05-13 22:49:12,081 - Wechaty - INFO - initPuppetEventBridge() puppet.on(room-leave) (listenerCount:1) registering...
2023-05-13 22:49:12,081 - Wechaty - INFO - initPuppetEventBridge() puppet.on(room-topic) (listenerCount:1) registering...
2023-05-13 22:49:12,081 - Wechaty - INFO - initPuppetEventBridge() puppet.on(scan) (listenerCount:1) registering...
2023-05-13 22:49:12,081 - Wechaty - INFO - starting puppet ...
2023-05-13 22:49:12,081 - PuppetService - INFO - init puppet ...
2023-05-13 22:49:12,082 - PuppetService - INFO - starting the puppet ...
'NoneType' object has no attribute 'encode'

Minimum reproducible code

import os, asyncio

from wechaty import Message, Wechaty

async def on_message(msg: Message): if msg.text() == 'ding': await msg.say('dong')

async def main(): bot = Wechaty() bot.on('message', on_message)

await bot.start()
print('[Python Wechaty] Ding Dong Bot started.')

asyncio.run(main())

zhayujie commented 1 year ago

I am also encountering the same issue.

Daineng commented 1 year ago

在Python 3.9上也遇到这样的问题,换到3.8就可以了。

muzikangkang commented 9 months ago

在Python 3.9上也遇到这样的问题,换到3.8就可以了。

不行呀,我换到python3.8.0还是不行

ridiculers commented 9 months ago

n 3.9上也遇到这样的问题,换

请问一下您解决了吗

puke3615 commented 6 months ago

俺也一样

puke3615 commented 6 months ago

在Python 3.9上也遇到这样的问题,换到3.8就可以了。

我现在换3.8试试,要是不行的话,把你头打疤

puke3615 commented 6 months ago

在Python 3.9上也遇到这样的问题,换到3.8就可以了。

我现在换3.8试试,要是不行的话,把你头打疤

可以个der,你个老6。。

(base) ➜  ~ python -V
Python 3.9.12
(base) ➜  ~ conda env remove -n python-wechaty-demo

Remove all packages in environment /Users/test/opt/anaconda3/envs/python-wechaty-demo:

(base) ➜  ~ conda create -n python-wechaty-demo python=3.8
Collecting package metadata (current_repodata.json): done
Solving environment: done

==> WARNING: A newer version of conda exists. <==
  current version: 4.12.0
  latest version: 24.3.0

Please update conda by running

    $ conda update -n base -c defaults conda

## Package Plan ##

  environment location: /Users/test/opt/anaconda3/envs/python-wechaty-demo

  added / updated specs:
    - python=3.8

The following NEW packages will be INSTALLED:

  ca-certificates    pkgs/main/osx-64::ca-certificates-2024.3.11-hecd8cb5_0
  libcxx             pkgs/main/osx-64::libcxx-14.0.6-h9765a3e_0
  libffi             pkgs/main/osx-64::libffi-3.4.4-hecd8cb5_0
  ncurses            pkgs/main/osx-64::ncurses-6.4-hcec6c5f_0
  openssl            pkgs/main/osx-64::openssl-3.0.13-hca72f7f_0
  pip                pkgs/main/osx-64::pip-23.3.1-py38hecd8cb5_0
  python             pkgs/main/osx-64::python-3.8.19-h5ee71fb_0
  readline           pkgs/main/osx-64::readline-8.2-hca72f7f_0
  setuptools         pkgs/main/osx-64::setuptools-68.2.2-py38hecd8cb5_0
  sqlite             pkgs/main/osx-64::sqlite-3.41.2-h6c40b1e_0
  tk                 pkgs/main/osx-64::tk-8.6.12-h5d9f67b_0
  wheel              pkgs/main/osx-64::wheel-0.41.2-py38hecd8cb5_0
  xz                 pkgs/main/osx-64::xz-5.4.6-h6c40b1e_0
  zlib               pkgs/main/osx-64::zlib-1.2.13-h4dc903c_0

Proceed ([y]/n)? y

Preparing transaction: done
Verifying transaction: done
Executing transaction: done
#
# To activate this environment, use
#
#     $ conda activate python-wechaty-demo
#
# To deactivate an active environment, use
#
#     $ conda deactivate

(base) ➜  ~ conda activate python-wechaty-demo
(python-wechaty-demo) ➜  ~ 2pc
(python-wechaty-demo) ➜  PycharmProjects cd python-wechaty-demo
(python-wechaty-demo) ➜  python-wechaty-demo pip i wechaty -i https://pypi.tuna.tsinghua.edu.cn/simple
ERROR: unknown command "i"
(python-wechaty-demo) ➜  python-wechaty-demo pip install wechaty -i https://pypi.tuna.tsinghua.edu.cn/simple
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting wechaty
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/e6/bf/4589a678c46b7f0fc3dc82edd3eb893b5243c662e4e4aa8e4b588ce5316d/wechaty-0.10.7-py3-none-any.whl (1.6 MB)
Collecting pyee (from wechaty)
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/16/cc/5cea8a0a0d3deb90b5a0d39ad1a6a1ccaa40a9ea86d793eb8a49d32a6ed0/pyee-11.1.0-py3-none-any.whl (15 kB)
Collecting requests (from wechaty)
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/70/8e/0e2d847013cb52cd35b38c009bb167a1a26b2ce6cd6965bf26b47bc0bf44/requests-2.31.0-py3-none-any.whl (62 kB)
Collecting qrcode (from wechaty)
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/24/79/aaf0c1c7214f2632badb2771d770b1500d3d7cbdf2590ae62e721ec50584/qrcode-7.4.2-py3-none-any.whl (46 kB)
Collecting lxml (from wechaty)
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/97/a8/92d88fe22b8caccdb0c1ff099e5ef90052b058b42671e69986e2262faa1f/lxml-5.1.0-cp38-cp38-macosx_10_9_x86_64.whl (4.8 MB)
Collecting wechaty-puppet>=0.4.19 (from wechaty)
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/1c/1e/8dcddaff8c0364c5248a8234a0da1d79963c66fd477c6a1ee96878d32f48/wechaty_puppet-0.4.23-py3-none-any.whl (34 kB)
Collecting wechaty-puppet-service>=0.8.9 (from wechaty)
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/d0/30/6c6b447a0945e4566e8fde40f5c701c1ab9dbbfaa5e20a8c799852e15c17/wechaty_puppet_service-0.8.10-py3-none-any.whl (17 kB)
Collecting quart (from wechaty)
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/9a/2c/681b4fcecefd98627a90dd5aecdc6b57ba18c9ce07e173d86a0b1274f20b/quart-0.19.4-py3-none-any.whl (77 kB)
Collecting opengraph-py3 (from wechaty)
  Using cached opengraph_py3-0.71-py3-none-any.whl
Collecting Quart-CORS (from wechaty)
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/60/fc/1ffe9042df05d48f5eaac4116708fee3f7bb18b696380cc4e3797c8fd510/quart_cors-0.7.0-py3-none-any.whl (8.0 kB)
Collecting APScheduler (from wechaty)
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/13/b5/7af0cb920a476dccd612fbc9a21a3745fb29b1fcd74636078db8f7ba294c/APScheduler-3.10.4-py3-none-any.whl (59 kB)
Collecting SQLAlchemy (from wechaty)
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/bb/53/332105ba836184be6db98d3d8f586d300dff549167c7fcfaca577b557039/SQLAlchemy-2.0.29-cp38-cp38-macosx_10_9_x86_64.whl (2.1 MB)
Collecting PyGithub (from wechaty)
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/84/2a/f7f72a06881493eeb763c207bea69f9ee4477c78200937b22b8b79f3acf9/PyGithub-2.3.0-py3-none-any.whl (354 kB)
Collecting wechaty-grpc~=0.20.19 (from wechaty-puppet-service>=0.8.9->wechaty)
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/08/7a/c41e73344bdd63b7d7decf5f3f99107c477987d29e8f5520f5c32df2d42b/wechaty_grpc-0.20.19-py3-none-any.whl (23 kB)
Collecting ping3 (from wechaty-puppet-service>=0.8.9->wechaty)
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/ee/87/a09dd341397d2dd1f565885dc0143e5c279b13f85eec71fdad02a9aaecf6/ping3-4.0.5-py3-none-any.whl (13 kB)
Collecting six>=1.4.0 (from APScheduler->wechaty)
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/d9/5a/e7c31adbe875f2abbb91bd84cf2dc52d792b5a01506781dbcf25c91daf11/six-1.16.0-py2.py3-none-any.whl (11 kB)
Collecting pytz (from APScheduler->wechaty)
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/9c/3d/a121f284241f08268b21359bd425f7d4825cffc5ac5cd0e1b3d82ffd2b10/pytz-2024.1-py2.py3-none-any.whl (505 kB)
Collecting tzlocal!=3.*,>=2.0 (from APScheduler->wechaty)
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/97/3f/c4c51c55ff8487f2e6d0e618dba917e3c3ee2caae6cf0fbb59c9b1876f2e/tzlocal-5.2-py3-none-any.whl (17 kB)
Collecting beautifulsoup4 (from opengraph-py3->wechaty)
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/b1/fe/e8c672695b37eecc5cbf43e1d0638d88d66ba3a44c4d321c796f4e59167f/beautifulsoup4-4.12.3-py3-none-any.whl (147 kB)
Collecting typing-extensions (from pyee->wechaty)
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/f9/de/dc04a3ea60b22624b51c703a84bbe0184abcd1d0b9bc8074b5d6b7ab90bb/typing_extensions-4.10.0-py3-none-any.whl (33 kB)
Collecting pynacl>=1.4.0 (from PyGithub->wechaty)
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/ce/75/0b8ede18506041c0bf23ac4d8e2971b4161cd6ce630b177d0a08eb0d8857/PyNaCl-1.5.0-cp36-abi3-macosx_10_10_universal2.whl (349 kB)
Collecting pyjwt>=2.4.0 (from pyjwt[crypto]>=2.4.0->PyGithub->wechaty)
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/2b/4f/e04a8067c7c96c364cef7ef73906504e2f40d690811c021e1a1901473a19/PyJWT-2.8.0-py3-none-any.whl (22 kB)
Collecting urllib3>=1.26.0 (from PyGithub->wechaty)
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/a2/73/a68704750a7679d0b6d3ad7aa8d4da8e14e151ae82e6fee774e6e0d05ec8/urllib3-2.2.1-py3-none-any.whl (121 kB)
Collecting Deprecated (from PyGithub->wechaty)
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/20/8d/778b7d51b981a96554f29136cd59ca7880bf58094338085bcf2a979a0e6a/Deprecated-1.2.14-py2.py3-none-any.whl (9.6 kB)
Collecting charset-normalizer<4,>=2 (from requests->wechaty)
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/13/82/83c188028b6f38d39538442dd127dc794c602ae6d45d66c469f4063a4c30/charset_normalizer-3.3.2-cp38-cp38-macosx_10_9_x86_64.whl (121 kB)
Collecting idna<4,>=2.5 (from requests->wechaty)
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/c2/e7/a82b05cf63a603df6e68d59ae6a68bf5064484a0718ea5033660af4b54a9/idna-3.6-py3-none-any.whl (61 kB)
Collecting certifi>=2017.4.17 (from requests->wechaty)
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/ba/06/a07f096c664aeb9f01624f858c3add0a4e913d6c96257acb4fce61e7de14/certifi-2024.2.2-py3-none-any.whl (163 kB)
Collecting pypng (from qrcode->wechaty)
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/3e/b9/3766cc361d93edb2ce81e2e1f87dd98f314d7d513877a342d31b30741680/pypng-0.20220715.0-py3-none-any.whl (58 kB)
Collecting aiofiles (from quart->wechaty)
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/c5/19/5af6804c4cc0fed83f47bff6e413a98a36618e7d40185cd36e69737f3b0e/aiofiles-23.2.1-py3-none-any.whl (15 kB)
Collecting blinker>=1.6 (from quart->wechaty)
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/fa/2a/7f3714cbc6356a0efec525ce7a0613d581072ed6eb53eb7b9754f33db807/blinker-1.7.0-py3-none-any.whl (13 kB)
Collecting click>=8.0.0 (from quart->wechaty)
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/00/2e/d53fa4befbf2cfa713304affc7ca780ce4fc1fd8710527771b58311a3229/click-8.1.7-py3-none-any.whl (97 kB)
Collecting flask>=3.0.0 (from quart->wechaty)
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/93/a6/aa98bfe0eb9b8b15d36cdfd03c8ca86a03968a87f27ce224fb4f766acb23/flask-3.0.2-py3-none-any.whl (101 kB)
Collecting hypercorn>=0.11.2 (from quart->wechaty)
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/17/9e/700d764316399c20fbe8e98c6fff903b5d3f950043cc2fcbd0831a42c953/hypercorn-0.16.0-py3-none-any.whl (59 kB)
Collecting importlib_metadata (from quart->wechaty)
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/2d/0a/679461c511447ffaf176567d5c496d1de27cbe34a87df6677d7171b2fbd4/importlib_metadata-7.1.0-py3-none-any.whl (24 kB)
Collecting itsdangerous (from quart->wechaty)
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/68/5f/447e04e828f47465eeab35b5d408b7ebaaaee207f48b7136c5a7267a30ae/itsdangerous-2.1.2-py3-none-any.whl (15 kB)
Collecting jinja2 (from quart->wechaty)
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/30/6d/6de6be2d02603ab56e72997708809e8a5b0fbfee080735109b40a3564843/Jinja2-3.1.3-py3-none-any.whl (133 kB)
Collecting markupsafe (from quart->wechaty)
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/4f/14/6f294b9c4f969d0c801a4615e221c1e084722ea6114ab2114189c5b8cbe0/MarkupSafe-2.1.5-cp38-cp38-macosx_10_9_x86_64.whl (14 kB)
Collecting werkzeug>=3.0.0 (from quart->wechaty)
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/c3/fc/254c3e9b5feb89ff5b9076a23218dafbc99c96ac5941e900b71206e6313b/werkzeug-3.0.1-py3-none-any.whl (226 kB)
Collecting greenlet!=0.4.17 (from SQLAlchemy->wechaty)
  Using cached greenlet-3.0.3-cp38-cp38-macosx_10_9_x86_64.whl
Collecting h11 (from hypercorn>=0.11.2->quart->wechaty)
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/95/04/ff642e65ad6b90db43e668d70ffb6736436c7ce41fcc549f4e9472234127/h11-0.14.0-py3-none-any.whl (58 kB)
Collecting h2>=3.1.0 (from hypercorn>=0.11.2->quart->wechaty)
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/2a/e5/db6d438da759efbb488c4f3fbdab7764492ff3c3f953132efa6b9f0e9e53/h2-4.1.0-py3-none-any.whl (57 kB)
Collecting priority (from hypercorn>=0.11.2->quart->wechaty)
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/5e/5f/82c8074f7e84978129347c2c6ec8b6c59f3584ff1a20bc3c940a3e061790/priority-2.0.0-py3-none-any.whl (8.9 kB)
Collecting taskgroup (from hypercorn>=0.11.2->quart->wechaty)
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/2c/e5/0f8dac3d9e6314f60a725cdc9ec01f45591ddd720e59f6a4ff8bdcdf82cd/taskgroup-0.0.0a4-py2.py3-none-any.whl (9.1 kB)
Collecting tomli (from hypercorn>=0.11.2->quart->wechaty)
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/97/75/10a9ebee3fd790d20926a90a2547f0bf78f371b2f13aa822c759680ca7b9/tomli-2.0.1-py3-none-any.whl (12 kB)
Collecting wsproto>=0.14.0 (from hypercorn>=0.11.2->quart->wechaty)
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/78/58/e860788190eba3bcce367f74d29c4675466ce8dddfba85f7827588416f01/wsproto-1.2.0-py3-none-any.whl (24 kB)
Collecting zipp>=0.5 (from importlib_metadata->quart->wechaty)
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/c2/0a/ba9d0ee9536d3ef73a3448e931776e658b36f128d344e175bc32b092a8bf/zipp-3.18.1-py3-none-any.whl (8.2 kB)
Collecting cryptography>=3.4.0 (from pyjwt[crypto]>=2.4.0->PyGithub->wechaty)
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/d9/f9/27dda069a9f9bfda7c75305e222d904cc2445acf5eab5c696ade57d36f1b/cryptography-42.0.5-cp37-abi3-macosx_10_12_x86_64.whl (3.1 MB)
Collecting cffi>=1.4.1 (from pynacl>=1.4.0->PyGithub->wechaty)
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/39/44/4381b8d26e9cfa3e220e3c5386f443a10c6313a6ade7acb314b2bcc0a6ce/cffi-1.16.0-cp38-cp38-macosx_10_9_x86_64.whl (182 kB)
Collecting backports.zoneinfo (from tzlocal!=3.*,>=2.0->APScheduler->wechaty)
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/4a/6d/eca004eeadcbf8bd64cc96feb9e355536147f0577420b44d80c7cac70767/backports.zoneinfo-0.2.1-cp38-cp38-macosx_10_14_x86_64.whl (35 kB)
Collecting betterproto (from wechaty-grpc~=0.20.19->wechaty-puppet-service>=0.8.9->wechaty)
  Using cached betterproto-1.2.5-py3-none-any.whl
Collecting grpclib (from wechaty-grpc~=0.20.19->wechaty-puppet-service>=0.8.9->wechaty)
  Using cached grpclib-0.4.7-py3-none-any.whl
Collecting soupsieve>1.2 (from beautifulsoup4->opengraph-py3->wechaty)
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/4c/f3/038b302fdfbe3be7da016777069f26ceefe11a681055ea1f7817546508e3/soupsieve-2.5-py3-none-any.whl (36 kB)
Collecting wrapt<2,>=1.10 (from Deprecated->PyGithub->wechaty)
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/fe/9e/d3bc95e75670ba15c5b25ecf07fc49941843e2678d777ca59339348d1c96/wrapt-1.16.0-cp38-cp38-macosx_10_9_x86_64.whl (37 kB)
Collecting pycparser (from cffi>=1.4.1->pynacl>=1.4.0->PyGithub->wechaty)
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/62/d5/5f610ebe421e85889f2e55e33b7f9a6795bd982198517d912eb1c76e1a53/pycparser-2.21-py2.py3-none-any.whl (118 kB)
Collecting hyperframe<7,>=6.0 (from h2>=3.1.0->hypercorn>=0.11.2->quart->wechaty)
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/d7/de/85a784bcc4a3779d1753a7ec2dee5de90e18c7bcf402e71b51fcf150b129/hyperframe-6.0.1-py3-none-any.whl (12 kB)
Collecting hpack<5,>=4.0 (from h2>=3.1.0->hypercorn>=0.11.2->quart->wechaty)
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/d5/34/e8b383f35b77c402d28563d2b8f83159319b509bc5f760b15d60b0abf165/hpack-4.0.0-py3-none-any.whl (32 kB)
Collecting stringcase (from betterproto->wechaty-grpc~=0.20.19->wechaty-puppet-service>=0.8.9->wechaty)
  Using cached stringcase-1.2.0-py3-none-any.whl
Collecting multidict (from grpclib->wechaty-grpc~=0.20.19->wechaty-puppet-service>=0.8.9->wechaty)
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/6c/13/97f4a2e0e26b7c6e2469de03f1efc255ce2f984a537c301d957762a23eba/multidict-6.0.5-cp38-cp38-macosx_10_9_x86_64.whl (30 kB)
Collecting exceptiongroup (from taskgroup->hypercorn>=0.11.2->quart->wechaty)
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/b8/9a/5028fd52db10e600f1c4674441b968cf2ea4959085bfb5b99fb1250e5f68/exceptiongroup-1.2.0-py3-none-any.whl (16 kB)
Installing collected packages: stringcase, pytz, pypng, zipp, wrapt, urllib3, typing-extensions, tomli, soupsieve, six, pyjwt, pycparser, priority, ping3, multidict, markupsafe, lxml, itsdangerous, idna, hyperframe, hpack, h11, greenlet, exceptiongroup, click, charset-normalizer, certifi, blinker, backports.zoneinfo, aiofiles, wsproto, werkzeug, tzlocal, taskgroup, SQLAlchemy, requests, qrcode, pyee, jinja2, importlib_metadata, h2, Deprecated, cffi, beautifulsoup4, wechaty-puppet, pynacl, opengraph-py3, hypercorn, grpclib, flask, cryptography, APScheduler, quart, betterproto, wechaty-grpc, Quart-CORS, PyGithub, wechaty-puppet-service, wechaty
Successfully installed APScheduler-3.10.4 Deprecated-1.2.14 PyGithub-2.3.0 Quart-CORS-0.7.0 SQLAlchemy-2.0.29 aiofiles-23.2.1 backports.zoneinfo-0.2.1 beautifulsoup4-4.12.3 betterproto-1.2.5 blinker-1.7.0 certifi-2024.2.2 cffi-1.16.0 charset-normalizer-3.3.2 click-8.1.7 cryptography-42.0.5 exceptiongroup-1.2.0 flask-3.0.2 greenlet-3.0.3 grpclib-0.4.7 h11-0.14.0 h2-4.1.0 hpack-4.0.0 hypercorn-0.16.0 hyperframe-6.0.1 idna-3.6 importlib_metadata-7.1.0 itsdangerous-2.1.2 jinja2-3.1.3 lxml-5.1.0 markupsafe-2.1.5 multidict-6.0.5 opengraph-py3-0.71 ping3-4.0.5 priority-2.0.0 pycparser-2.21 pyee-11.1.0 pyjwt-2.8.0 pynacl-1.5.0 pypng-0.20220715.0 pytz-2024.1 qrcode-7.4.2 quart-0.19.4 requests-2.31.0 six-1.16.0 soupsieve-2.5 stringcase-1.2.0 taskgroup-0.0.0a4 tomli-2.0.1 typing-extensions-4.10.0 tzlocal-5.2 urllib3-2.2.1 wechaty-0.10.7 wechaty-grpc-0.20.19 wechaty-puppet-0.4.23 wechaty-puppet-service-0.8.10 werkzeug-3.0.1 wrapt-1.16.0 wsproto-1.2.0 zipp-3.18.1
(python-wechaty-demo) ➜  python-wechaty-demo python -V
Python 3.8.19
(python-wechaty-demo) ➜  python-wechaty-demo python app.py 
Traceback (most recent call last):
  File "app.py", line 10, in <module>
    from wechaty import Wechaty, Contact, WechatyOptions
  File "/Users/test/opt/anaconda3/envs/python-wechaty-demo/lib/python3.8/site-packages/wechaty/__init__.py", line 54, in <module>
    from .wechaty import (
  File "/Users/test/opt/anaconda3/envs/python-wechaty-demo/lib/python3.8/site-packages/wechaty/wechaty.py", line 72, in <module>
    from wechaty.user.url_link import UrlLink
  File "/Users/test/opt/anaconda3/envs/python-wechaty-demo/lib/python3.8/site-packages/wechaty/user/__init__.py", line 8, in <module>
    from .message         import Message
  File "/Users/test/opt/anaconda3/envs/python-wechaty-demo/lib/python3.8/site-packages/wechaty/user/message.py", line 51, in <module>
    from .url_link import UrlLink
  File "/Users/test/opt/anaconda3/envs/python-wechaty-demo/lib/python3.8/site-packages/wechaty/user/url_link.py", line 10, in <module>
    from urllib3 import get_host
ImportError: cannot import name 'get_host' from 'urllib3' (/Users/test/opt/anaconda3/envs/python-wechaty-demo/lib/python3.8/site-packages/urllib3/__init__.py)
(python-wechaty-demo) ➜  python-wechaty-demo pip install "urllib3<2.0.0"
Collecting urllib3<2.0.0
  Using cached urllib3-1.26.18-py2.py3-none-any.whl.metadata (48 kB)
Using cached urllib3-1.26.18-py2.py3-none-any.whl (143 kB)
Installing collected packages: urllib3
  Attempting uninstall: urllib3
    Found existing installation: urllib3 2.2.1
    Uninstalling urllib3-2.2.1:
      Successfully uninstalled urllib3-2.2.1
Successfully installed urllib3-1.26.18
(python-wechaty-demo) ➜  python-wechaty-demo python app.py              
2024-03-28 12:37:47,639 - Wechaty - INFO - init_puppet_event_bridge() <<wechaty_puppet_service.puppet.PuppetService object at 0x7f89164899a0>>
2024-03-28 12:37:47,639 - Wechaty - INFO - initPuppetEventBridge() puppet.on(dong) (listenerCount:1) registering...
2024-03-28 12:37:47,639 - Wechaty - INFO - initPuppetEventBridge() puppet.on(error) (listenerCount:1) registering...
2024-03-28 12:37:47,639 - Wechaty - INFO - initPuppetEventBridge() puppet.on(heart-beat) (listenerCount:1) registering...
2024-03-28 12:37:47,639 - Wechaty - INFO - initPuppetEventBridge() puppet.on(ready) (listenerCount:1) registering...
2024-03-28 12:37:47,639 - Wechaty - INFO - receive <reset> event <%s>
2024-03-28 12:37:47,639 - Wechaty - INFO - initPuppetEventBridge() puppet.on(reset) (listenerCount:0) registering...
2024-03-28 12:37:47,640 - Wechaty - INFO - initPuppetEventBridge() puppet.on(friendship) (listenerCount:1) registering...
2024-03-28 12:37:47,640 - Wechaty - INFO - initPuppetEventBridge() puppet.on(login) (listenerCount:1) registering...
2024-03-28 12:37:47,640 - Wechaty - INFO - initPuppetEventBridge() puppet.on(logout) (listenerCount:1) registering...
2024-03-28 12:37:47,640 - Wechaty - INFO - initPuppetEventBridge() puppet.on(message) (listenerCount:1) registering...
2024-03-28 12:37:47,640 - Wechaty - INFO - initPuppetEventBridge() puppet.on(room-invite) (listenerCount:1) registering...
2024-03-28 12:37:47,640 - Wechaty - INFO - initPuppetEventBridge() puppet.on(room-join) (listenerCount:1) registering...
2024-03-28 12:37:47,640 - Wechaty - INFO - initPuppetEventBridge() puppet.on(room-leave) (listenerCount:1) registering...
2024-03-28 12:37:47,640 - Wechaty - INFO - initPuppetEventBridge() puppet.on(room-topic) (listenerCount:1) registering...
2024-03-28 12:37:47,640 - Wechaty - INFO - initPuppetEventBridge() puppet.on(scan) (listenerCount:1) registering...
2024-03-28 12:37:47,640 - Wechaty - INFO - starting puppet ...
2024-03-28 12:37:47,640 - PuppetService - INFO - init puppet ...
2024-03-28 12:37:47,641 - PuppetService - INFO - starting the puppet ...
'NoneType' object has no attribute 'encode'
puke3615 commented 6 months ago

老哥们,直接换JS吧,连docker都不用配置,npm install wechaty 之后直接撸代码,亲测有效

const {WechatyBuilder} = require('wechaty')

const wechaty = WechatyBuilder.build({
    puppetOptions: {
        uos: true,
    }
})
wechaty
    .on('scan', (qrcode, status) => console.log(`Scan QR Code to login: ${status}\nhttps://wechaty.js.org/qrcode/${encodeURIComponent(qrcode)}`))
    .on('login', user => console.log(`User ${user} logged in`))
    .on('message', async (message) => {
        console.log(`Message: ${message}`)
        if (message.text() === '你好呀') {
            await message.say('哈哈啊');
        }
    })
wechaty.start()
puke3615 commented 6 months ago

啊,我跟进来了,找到原因了,在这里:

image

这里的vNone,直接调用了encode,所以报错了。

puke3615 commented 6 months ago

h2这个库的锅,阿西吧。。

image
lethe3000 commented 6 months ago

有绕过的方法吗

mingkid commented 4 months ago

h2这个库的锅,阿西吧。。 image

跟这个库没关系,看调用堆栈,估计传到 h2 之前就已经为 None 了。

gaozhidf commented 6 days ago

啊,我跟进来了,找到原因了,在这里: image 这里的vNone,直接调用了encode,所以报错了。

里面的内容是这个,看起来是:authority为None,设置环境变量WECHATY_PUPPET_SERVICE_TOKEN就可以使authority有值

[(':method', 'POST'), (':scheme', 'http'), (':path', '/wechaty.Puppet/Start'), (':authority', None), ('te', 'trailers'), ('content-type', 'application/grpc'), ('user-agent', 'grpc-python-grpclib/0.4.7 (linux; cpython/3.10.14)')]