I need to make my code backwards compatible with python2.6 and BeautifulSoup 3. My code was written using python2.7 and at this case using BS4. But when I try to run it at squeezy server, I get this error (it has python2.6 and bs3):
try:
from bs4 import BeautifulSoup
except ImportError:
from BeautifulSoup import BeautifulSoup
gmp = open(fname, 'r')
soup = BeautifulSoup(gmp)
p = soup.body.div.find_all('p')
p = soup.body.div.find_all('p')
TypeError: 'NoneType' object is not callable
If I change to:
p = soup.body.div.findAll('p')
then I get this error:
p = soup.body.div.findAll('p')
TypeError: 'NoneType' object is not callable
Update of thrown error
File "/home/user/openerp/7.0/addons/my_module/models/gec.py", line 401, in parse_html_data
p = soup.body.div.findAll('p') #used findAll instead of find_all for backwards compatability to bs3 version
TypeError: 'NoneType' object is not callable
Either way, both approaches work on my Ubuntu with python2.7 and bs4, but not on squeezy. Is there any other difference between those versions that I don't see/know and gives me this error?
from BeautifulSoup import BeautifulSoup
(version 3) when using version 4 only syntax. – Abscission