【问题标题】:Python six library error while using spynner使用 spynner 时出现 Python 六库错误
【发布时间】:2014-07-30 16:17:01
【问题描述】:

我在我的电脑上安装了 python、pip 和 easy_install。 并使用 pip 命令安装了 spynner 但我在安装 autopy 时出错, 但我通过使用 easy_install 解决了它,安装后,我尝试使用 spynner 但它给我一个崩溃错误......

这就是我所拥有的 import spynner br = spynner.Browser() br.load("@987654321@") 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,但给了我同样的错误。 任何人都可以解决这个错误?

【问题讨论】:

    标签: python python-2.7 easy-install spynner


    【解决方案1】:

    我遇到了同样的问题。我的直接解决方案是编辑六模块的 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'\\\\'))
    

    这只是一种解决方法。希望对您有所帮助。

    【讨论】:

      【解决方案2】:

      我的同事找到了解决方案。

      更改安装方法。

      1. 安装 Python
      2. 下载 setuptools, spynner
      3. 使用 ez_setup.py 安装 setuptools
      4. 安装 spynner
      5. 安装 PyQt4

      也许应该最后安装 PyQt4

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2021-11-17
        • 1970-01-01
        • 2011-10-28
        • 1970-01-01
        • 2019-04-17
        • 1970-01-01
        • 2020-09-04
        相关资源
        最近更新 更多