youfou / wxpy

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

Python27报错,global name 'FileNotFoundError' is not defined #227

Open sky7758 opened 7 years ago

sky7758 commented 7 years ago

Please press confirm on your phone. Traceback (most recent call last): File "C:/Users/king/Desktop/tools/zhuang/wechatRobot.py", line 3, in bot = Bot() File "C:\Python27\lib\site-packages\wxpy\api\bot.py", line 88, in init except FileNotFoundError as e: NameError: global name 'FileNotFoundError' is not defined

sky7758 commented 7 years ago

改成 IOError 又包这个错 Please press confirm on your phone. Traceback (most recent call last): File "C:/Users/king/Desktop/tools/zhuang/wechatRobot.py", line 3, in bot = Bot() File "C:\Python27\lib\site-packages\wxpy\api\bot.py", line 86, in init loginCallback=login_callback, exitCallback=logout_callback File "C:\Python27\lib\site-packages\itchat\components\register.py", line 36, in auto_login loginCallback=loginCallback, exitCallback=exitCallback) File "C:\Python27\lib\site-packages\itchat\components\login.py", line 53, in login status = self.check_login() File "C:\Python27\lib\site-packages\itchat\components\login.py", line 137, in check_login if process_login_info(self, r.text): File "C:\Python27\lib\site-packages\itchat\components\login.py", line 172, in process_login_info for node in xml.dom.minidom.parseString(r.text).documentElement.childNodes: File "C:\Python27\lib\xml\dom\minidom.py", line 1928, in parseString return expatbuilder.parseString(string) File "C:\Python27\lib\xml\dom\expatbuilder.py", line 940, in parseString return builder.parseString(string) File "C:\Python27\lib\xml\dom\expatbuilder.py", line 223, in parseString parser.Parse(string, True) UnicodeEncodeError: 'ascii' codec can't encode characters in position 31-60: ordinal not in range(128)

Lauren-Guo commented 7 years ago

Python 2.7.10 Traceback (most recent call last): File "test.py", line 3, in bot = Bot() File "/Library/Python/2.7/site-packages/wxpy/api/bot.py", line 88, in init except FileNotFoundError as e: NameError: global name 'FileNotFoundError' is not defined.

您的问题解决了吗?

seventh17 commented 7 years ago

我也是遇到 FileNotFoundError,按照fix commit的建议,改成IOError,跟sky7758同样的错误。估计是r.text中的问题。在itchat/login.py中把r.text打印出来,结果如下:

1203为了你的帐号安全,此微信号已不允许登录网页微信。你可以使用Windows微信或Mac微信在电脑端登录。Windows微信下载地址:https://pc.weixin.qq.com Mac微信下载地址:https://mac.weixin.qq.com

用别人的微信登录,无恙,问题一目了然~

showniu commented 6 years ago

我也是这样的问题,我用的是新注册的微信号,在wx.qq.com使用网页网都登陆不上,这和项目本身应该没有关系。

weixin
ShanChuangxin commented 6 years ago

上边的两个说是微信号的问题,实际上bot = Bot()这一步就直接 报错了,根本就没到微信扫码的步骤就已经报错了,所以说明和微信是没有关系的,因为“我还没有使劲,他就倒下了”

seventh17 commented 6 years ago

@ShanChuangxin 很久之前弄过,好像是拉二维码的时候异常,抛出的FileNotFound异常没有定义。详细的记不起了,也懒得回头去翻代码,单说是不是微信号的问题。 异常信息中不是有 r.text 这个变量吗?把变量内容print出来: “1203为了你的帐号安全,此微信号已不允许登录网页微信。你可以使用Windows微信或Mac微信在电脑端登录。Windows微信下载地址:https://pc.weixin.qq.com Mac微信下载址:https://mac.weixin.qq.com”如果还没看明白,我给解释一下,这是腾讯那边返回的信息。 扫码之前需要从远端拉二维码下来,我的理解是拉的时候腾讯不让,同时给出了以上错误信息。 所以跟微信号是有关系的。

code4security commented 5 years ago

我也是遇到 FileNotFoundError,按照fix commit的建议,改成IOError,跟sky7758同样的错误。估计是r.text中的问题。在itchat/login.py中把r.text打印出来,结果如下:

1203为了你的帐号安全,此微信号已不允许登录网页微信。你可以使用Windows微信或Mac微信在电脑端登录。Windows微信下载地址:https://pc.weixin.qq.com Mac微信下载地址:https://mac.weixin.qq.com

用别人的微信登录,无恙,问题一目了然~

QQwx Thanks,复现和你的情况一致!