Error installing BeautifoulSoup using pip

1

I'm trying to install the BeautifulSoup library with pip for Python 3.6:

$ pip install beautifulSoup

But he throws me an error:

(myvenv) eduardorr21@eduardoreyes21 ~/Documents/WebScraping $ pip 
install beautifulSoup
beautifulSoup
Using cached BeautifulSoup-3.2.1.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/tmp/pip-install-9caehp9_/beautifulSoup/setup.py", line 22
    print "Unit tests have failed!"
                                  ^
  SyntaxError: Missing parentheses in call to 'print'

----------------------------------------
  Command "python setup.py egg_info" failed with error code 1 in 
/tmp/pip-install-9caehp9_/beautifulSoup/

Supposedly the file setup.py is not updated and I've updated it.

    
asked by Eduardo Reyes 08.04.2018 в 08:23
source

1 answer

1

You are installing the wrong package. beautifulsoup refers to the BeautifulSoup 3.x branch in PyPi ( as you can see in the trace of the error), it is a package marked as obsolete and only compatible with Python 2 (hence the error with print in its setup.py ). It is maintained only by backward compatibility with code that once used this version and has not been ported.

You must install BeautifulSoup 4.x . In the official documentation clarify it very well:

  

The BeautifulSoup package is probably not what you want. That's the previous best release, Beautiful Soup 3. Lots of software uses BS3, so it's still available, but if you're writing new code you should install beautifulsoup4.

Therefore you must do:

pip install beautifulsoup4

Do not forget then import the package appropriately in your script:

from bs4 import BeautifulSoup
    
answered by 08.04.2018 в 10:09