我在我的电脑上安装了python,pip和easy_install。 并使用pip命令安装spynner但是我在autopy安装时遇到错误, 但我通过使用easy_install解决了它,安装后,我试图使用spynner,但它给我一个崩溃错误...
这是我所拥有的
import spynner
br = spynner.Browser()
br.load("http://www.google.com")
Traceback (most recent call last):
File "C:\Python27\lib\site-packages\spynner\browser.py", line 1674, in createRequest
url = six.u(toString(request.url()))
File "C:\Python27\lib\site-packages\six.py", line 589, in u
return unicode(s.replace(r'\', r'\\'), "unicode_escape")
TypeError: decoding Unicode is not supported
在我的Windows 7 64bit Ultimate和Python 2.7.8 64bit
上我也尝试了32位python但是给了我同样的错误。 任何人都可以解决这个错误吗?
答案 0 :(得分:4)
我遇到了同样的问题。我的直接解决方案是编辑六个模块的u()方法。
原来是:
def u(s):
return unicode(s.replace(r'\\', r'\\\\'), "unicode_escape")
我把它改为:
def u(s):
try:
return unicode(s.replace(r'\\', r'\\\\'), "unicode_escape")
except TypeError as e:
if "decoding Unicode is not supported" in str(e):
return unicode(s.replace(r'\\', r'\\\\'))
这只是一种解决方法。希望它有所帮助。
答案 1 :(得分:0)
我的同事找到了解决方案。
更改安装方法。
可能最后安装PyQt4