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


Groups > comp.lang.python > #4824

Re: BeautifulSoup import error

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <nirina.raseliarison@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; '2.x': 0.05; '3.2': 0.07; 'version?': 0.07; 'python': 0.07; '>>>>': 0.09; 'attribute': 0.09; 'subprocess': 0.09; 'scripts': 0.10; 'subject:error': 0.12; 'syntax': 0.12; '448': 0.16; 'subject:import': 0.16; 'invalid': 0.16; 'traceback': 0.16; '(most': 0.16; 'stick': 0.19; 'cc:2**0': 0.20; 'header:In-Reply-To:1': 0.22; 'linux,': 0.22; 'last):': 0.23; 'least,': 0.23; 'tool,': 0.23; 'fix': 0.24; "i'm": 0.26; 'object': 0.27; 'raise': 0.29; 'string': 0.29; 'error': 0.29; 'skip:" 30': 0.29; 'skip:( 20': 0.31; 'cc:addr:gmail.com': 0.31; 'charset:iso-8859-15': 0.31; 'converts': 0.31; 'differences': 0.31; 'skip:% 20': 0.31; 'yes.': 0.31; "can't": 0.31; "skip:' 10": 0.32; 'import': 0.32; 'to:addr:python-list': 0.32; 'got': 0.34; 'there': 0.35; 'file': 0.35; 'header:User-Agent:1': 0.35; '"",': 0.35; 'received:209.85.216.46': 0.35; 'received:mail- qw0-f46.google.com': 0.35; 'received:209.85': 0.37; 'received:google.com': 0.38; 'but': 0.38; 'here,': 0.39; 'help': 0.39; 'much.': 0.39; 'skip:s 30': 0.39; 'to:addr:python.org': 0.39; 'received:209': 0.39; 'solution': 0.40; 'header:Received:5': 0.40; 'received:196': 0.61; 'below.': 0.64
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:content-type:cc:in-reply-to:references:subject :to:mime-version:content-transfer-encoding:from:date:message-id :user-agent; bh=7R1AvQUddyMDZBumb/9xdmxb814/zl3s0nTKxoIlhtQ=; b=HLIp7jhhmBZ5RZPajrQbqyshhMKGFfwYeSTHNMIJ7OGNeSJiboA3DTNqmdEgCs+r10 4Cui4Yr7ec5aOHzH4gDCcW1uj4gENtblXGh8+8aEUx4oRiC+JIxGt70Bk5KfnfSGURDF z62MLKre+PBIwXSVv+u7PEYVQskjxgRmrrs6k=
DomainKey-Signature a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=content-type:cc:in-reply-to:references:subject:to:mime-version :content-transfer-encoding:from:date:message-id:user-agent; b=xgSlOglAqUhtD/BJ6rAQWDpIYgcH53SurET8xQy6Dwz5W8Aj28Kf3VvdaFuM3LdAR4 ALqt5wd/OhUWcPBkQK6TUIhYNa2q5FBj9o6eCeuP6WaH0o7+tP3e4HjMFyH29uK1e6Xj s2AFx3F9oL7t3N/UwcP33RiuTPPX/wYTC8b/o=
Content-Type text/plain; charset=iso-8859-15; format=flowed; delsp=yes
In-Reply-To <6584008a.222d5.12fc2f1358d.Coremail.1011_wxy@163.com>
References <6584008a.222d5.12fc2f1358d.Coremail.1011_wxy@163.com>
Subject Re: BeautifulSoup import error
To python-list@python.org
MIME-Version 1.0
Content-Transfer-Encoding 7bit
From nirinA raseliarison <nirina.raseliarison@gmail.com>
Date Fri, 06 May 2011 15:27:41 +0300
User-Agent Opera Mail/11.01 (Win32)
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.1243.1304684825.9059.python-list@python.org> (permalink)
Lines 52
NNTP-Posting-Host 82.94.164.166
X-Trace 1304684825 news.xs4all.nl 41113 [::ffff:82.94.164.166]:40216
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:4824

Show key headers only | View raw


[1011_wxy]

> I got a import error when I use Python 3.2 to import BeautifulSoup 3.2.0

the error i see is a SyntaxError.

> Is there any differences between Python 3.2 and other version?

yes. and there is a tool, 2to3, which converts
Python 2.x scripts to work with 3.x.

> 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

a quick fix here, change:

     raise AttributeError, "'%s' object has no attribute '%s'"
%(self.__class__.__name__, attr)

to:

     raise AttributeError("'%s' object has no attribute '%s'"
%(self.__class__.__name__, attr))

enclose the string message with parentheses.
at least, you will not get the SyntaxError.
but a better solution is to use 2to3.

i don't use BeautifulSoup, and i'm still stick with
Python2.5.4 on windows, so can't help much.

with Linux, it is just:

   2to3 a_python_file_or_a_dir_package

on windows, i don't know, maybe:

   import subprocess
   subprocess.Popen(('python.exe', 'Tools/Scripts/2to3.py', 'the_package'))

--
nirinA

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


Thread

Re: BeautifulSoup import error nirinA raseliarison <nirina.raseliarison@gmail.com> - 2011-05-06 15:27 +0300

csiph-web