Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #4788

BeautifulSoup import error

Return-Path <1011_wxy@163.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'else:': 0.03; 'value,': 0.04; '&gt;&gt;&gt;': 0.05; '3.2': 0.07; 'backwards': 0.07; 'version?': 0.07; 'python': 0.07; '"""': 0.09; 'attribute': 0.09; 'encoding:': 0.09; '>>>': 0.12; 'subject:error': 0.12; 'syntax': 0.12; 'def': 0.13; '448': 0.16; 'received:220.181.13': 0.16; 'subject:import': 0.16; 'invalid': 0.16; 'traceback': 0.16; '(most': 0.16; 'to:name:python-list': 0.19; 'last):': 0.23; 'skip:( 30': 0.24; 'skip:_ 20': 0.24; 'object': 0.27; 'raise': 0.29; 'string': 0.29; 'error': 0.29; 'skip:" 30': 0.29; 'class': 0.29; "won't": 0.30; 'skip:( 20': 0.31; 'differences': 0.31; 'value)': 0.31; 'import': 0.32; 'called': 0.32; 'to:addr:python- list': 0.32; 'skip:& 10': 0.34; 'skip:" 10': 0.34; 'got': 0.34; 'there': 0.35; 'file': 0.35; 'point': 0.35; '"",': 0.35; 'self': 0.37; 'but': 0.38; 'skip:" 20': 0.38; 'lets': 0.39; 'to:addr:python.org': 0.39; 'how': 0.39; 'received:220': 0.60; 'below.': 0.64; 'dear': 0.64; 'received:220.181': 0.72; 'from:addr:163.com': 0.77; 'received:163.com': 0.77; 'correctly?': 0.84; 'friends:': 0.93
Date Fri, 6 May 2011 09:37:38 +0800
From "1011_wxy"<1011_wxy@163.com>
To "python-list"<python-list@python.org>
Subject BeautifulSoup import error
MIME-Version 1.0
Content-Type multipart/alternative; boundary="__=_Part_Boundary_007_028757.016777"
X-Mailer NetEase Flash Mail 2.0.2.30
X-Priority 3 (Normal)
X-Originating-IP [220.248.57.11]
X-CM-TRANSID 6cKowKDrm_MvUMNNY4YDAA--.3968W
X-CM-SenderInfo yrqrisxz01qiywtou0bp/1tbiMBY3R0iNbWUmZgABsa
X-Coremail-Antispam 1U5529EdanIXcx71UUUUU7vcSsGvfC2KfnxnUU==
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.1213.1304645692.9059.python-list@python.org> (permalink)
Lines 144
NNTP-Posting-Host 82.94.164.166
X-Trace 1304645692 news.xs4all.nl 81479 [::ffff:82.94.164.166]:44137
X-Complaints-To abuse@xs4all.nl
Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.stben.net!border3.nntp.ams.giganews.com!Xbb.tags.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:4788

Show key headers only | View raw


[Multipart message — attachments visible in raw view] - view raw

Dear friends:

I got a import error when I use Python 3.2 to import BeautifulSoup 3.2.0 .
Is there any differences between Python 3.2 and other version? This is my first time to use Python3.2 .
And the error message will be as below.


>>> from BeautifulSoup import BeautifulSoup
Traceback (most recent call last):
  File "<pyshell#2>", line 1, in <module>
    from BeautifulSoup import BeautifulSoup
  File "C:\Python32\BeautifulSoup.py", line 448
    raise AttributeError, "'%s' object has no attribute '%s'" % (self.__class__.__name__, attr)
                        ^
SyntaxError: invalid syntax



And the error place point to BeautifulSoup

class NavigableString(unicode, PageElement):
    def __new__(cls, value):
        """Create a new NavigableString.
        When unpickling a NavigableString, this method is called with
        the string in DEFAULT_OUTPUT_ENCODING. That encoding needs to be
        passed in to the superclass's __new__ or the superclass won't know
        how to handle non-ASCII characters.
        """
        if isinstance(value, unicode):
            return unicode.__new__(cls, value)
        return unicode.__new__(cls, value, DEFAULT_OUTPUT_ENCODING)
    def __getnewargs__(self):
        return (NavigableString.__str__(self),)
    def __getattr__(self, attr):
        """text.string gives you text. This is for backwards
        compatibility for Navigable*String, but for CData* it lets you
        get the string without the CData wrapper."""
        if attr == 'string':
            return self
        else:
            raise AttributeError, "'%s' object has no attribute '%s'" % (self.__class__.__name__, attr)
    def __unicode__(self):
        return str(self).decode(DEFAULT_OUTPUT_ENCODING)
    def __str__(self, encoding=DEFAULT_OUTPUT_ENCODING):
        if encoding:
            return self.encode(encoding)
        else:
            return self


Did I make any mistake?
How can I do this correctly?



2011-05-06



Kerry

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

BeautifulSoup import error "1011_wxy"<1011_wxy@163.com> - 2011-05-06 09:37 +0800

csiph-web