7

I keep getting an error when I try to install some basic python libraries like BeautifulSoup. The error looks like this:

error screenshot

What exactly does that mean, and how do I fix it? I already tried these commands:

pip install --upgrade
pip install
pip install unroll

As it was suggested in other posts, but this didn't seem to help either..

wjandrea
  • 14,504

3 Answers3

1

The syntax error Missing parenthesis... clearly shows you have a python3 interpreter trying to execute python2 code. I do not know where you read the installation instructions for 'BeautifulSoup' but according to the documentation, you have two different packages, one for python2 and the other one for python3.
They are installed respectively:

$ apt-get install python-bs4 (for Python 2)

$ apt-get install python3-bs4 (for Python 3)

It is also possible to use pip but the recommended package is beautifulsoup4. As a footnote, they state 'The BeautifulSoup package is probably not what you want. That’s the previous major release'.

0

Force python2 version of pip:

sudo pip2 install BeautifulSoup

You may have a custom setup for pip which could be pointing to pip3. So how did you install pip? Could you check & add to the question output of:

ls -l $(which pip); dpkg -S /usr/bin/pip
user.dz
  • 49,176
-1

You are installing the wrong package. BeutifulSoup is version 3.2.1 and back from 2012. You want beautifulsoup4.

Also, instead of using pip you can just use apt. The package name is python-bs4.

The text in orange suggests that you messed up your installs by mixing and matching using sudo and not using sudo and possibly using --user.

Also, is your pip version up to date? python -m pip install --upgrade pip

Melebius
  • 11,750
Diffeo
  • 51