youfou / wxpy

微信机器人 / 可能是最优雅的微信个人号 API ✨✨
http://wxpy.readthedocs.io
MIT License
13.99k stars 2.38k forks source link

python2 support? #9

Open MultiPath opened 7 years ago

MultiPath commented 7 years ago

Will it support python 2?

youfou commented 7 years ago

Not shortly. I'm currently working on the Python 3.x version.

BTW, have you tried 3to2? https://pypi.python.org/pypi/3to2

MultiPath commented 7 years ago

Yes, I tried. But unfortunately, it did not work.

bluedazzle commented 7 years ago

@MultiPath Try this: https://github.com/bluedazzle/wxpy/tree/py2 I write a py2 version, but not test completely.

install this test verison:

git clone -b py2 git@github.com:bluedazzle/wxpy.git
cd wxpy
python setup.py install
grunmin commented 7 years ago

@bluedazzle 目前的情况是, 无法转发消息

Traceback (most recent call last):
  File "D:\Program Files\Python27\lib\threading.py", line 801, in __bootstrap_inner
    self.run()
  File "D:\Program Files\Python27\lib\threading.py", line 754, in run
    self.__target(*self.__args, **self.__kwargs)
  File "D:\Program Files\Python27\lib\site-packages\wxpy\api\bot.py", line 479, in _list
en
    self._process_message(msg)
  File "D:\Program Files\Python27\lib\site-packages\wxpy\api\bot.py", line 422, in _proc
ess_message
    config = self.registered.get_config(msg)
  File "D:\Program Files\Python27\lib\site-packages\wxpy\api\messages\registered.py", li
ne 40, in get_config
    if (isinstance(chat, type) and isinstance(msg.chat, chat)) or chat == msg.chat:
  File "D:\Program Files\Python27\lib\site-packages\wxpy\api\chats\chat.py", line 345, i
n __eq__
    return hash(self) == hash(other)
TypeError: unhashable type: 'Chats'

UPDATE: 测试python3版本也有这个问题, 所以先忽略.

youfou commented 7 years ago

@grunmin 从报错信息来看,并非转发消息的问题。 是不是注册的聊天对象包含了“列表中的列表”?类似 [1, 2, [3]] 中的 [3]。 这个问题可能是因为程序中使用 .search() 后没有指定下标 (搜索结果总是为列表)。

youfou commented 7 years ago

Hello @MultiPath

The Python 2.x support branch is merged into master finally, and I just released a new version.

So, you can try to install wxpy with pip2 now 😄

pip2 install -U wxpy