Python six library error while using spynner

887 Views Asked by At

I installed python, pip and easy_install on my computer. and with pip command installed spynner but i've got an error with autopy installation, but i solved it by using easy_install and after installation, i tried to use spynner but it give me an error with crashing...

Here's what i've got 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

On my Windows 7 64bit Ultimate and Python 2.7.8 64bit

I tried 32bit python also but gave me same error. Anyone can solve this errror?

2

There are 2 best solutions below

0
On

My co-worker found solution.

Changing installation method.

  1. Install Python
  2. Download setuptools, spynner
  3. Install setuptools using ez_setup.py
  4. Install spynner
  5. Install PyQt4

Maybe PyQt4 should be installed at last

0
On

I had the same problem. My immediate solution was to edit the u() method of the six module.

Originally it was:

def u(s):
    return unicode(s.replace(r'\\', r'\\\\'), "unicode_escape")

I changed it to:

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'\\\\'))

It's just a workaround. Hope it helps.