Just installed BeautifulSoup Python 3.3.0

Does anyone know how to fix this. I am using Mac OS 10.8.2

>>> from bs4 import BeautifulSoup
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/bs4/__init__.py", line 359
    print soup.prettify()
             ^
SyntaxError: invalid syntax
+3
source share
3 answers

Python 3 printhas a function; it should be:

print(soup.prettify())

Install bs4correctly or use a newer version if this is a mistake. beautifulsoup4==4.1.3works great on Python 3.3.

+6
source

https://github.com/il-vladislav/BeautifulSoup4 Just copy this to the Lib directory. This is a fixed version for Python 3.3.

+2
source

Beautiful Soup 4 Python 2 (2.6+), Python 3.

Beautiful Soup is licensed under the MIT license, so you can also download the tarball, drop the bs4 / directory into almost any Python application (or the library path), and start using it right away. If you want to do this under Python 3, you will need to manually convert the code using 2to3.

http://www.crummy.com/software/BeautifulSoup/

using python ../ python33 / Tools / Script / 2to3.py -w beautifulsoup4-4.3.2 that's fine

0
source

Source: https://habr.com/ru/post/1662249/


All Articles