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..

  • Looks like there's some python 2.7 code in the install script, because there are no parentheses in the print statement. Feb 9, 2017 at 18:54
  • Can you try with the -H parameter for sudo as suggested in the warning message ?
    – albert j
    Feb 9, 2017 at 19:14
  • I thought the -H parameter only changes that the sudo command can only change things in the home directory instead of from root, because otherwise someone might be able to install malicious code somewhere. Am I wrong? Also, still getting the same error even with -H Feb 9, 2017 at 22:48
  • Does noone know how to solve this? I'm relatively new to linux and programming and this is really discouraging to be honest, I'm failing when I haven't even gotten started... Feb 11, 2017 at 10:59
  • Same issue, on Ubuntu 16.04 with Python 2.7.12. This post (stackoverflow.com/questions/35991403/…) has a bunch of answers but none of them work
    – Matifou
    Nov 7, 2017 at 20:19

3 Answers 3


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'.

  • 1
    Thanks for the answer! This is confusing but actually I posted the bounty for an issue I believed was the same as package BeautifulSoup, and is actually not (about unroll and rpy2), so opened a new post: askubuntu.com/questions/975523/… thanks!
    – Matifou
    Nov 13, 2017 at 21:30

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
  • Sorry it's a little confusing, my question is actually about package rpy2 and unroll, which produce also same error code (while beautiful soup can be solved by sudo) . Using pip2 leads to same error: pip2 install rpy2==2.2.7: Command "python setup.py egg_info" failed with error code 1. I get running your code: -rwxr-xr-x 1 root root 204 Oct 2 10:14 /usr/local/bin/pip python-pip: /usr/bin/pip. Thanks!
    – Matifou
    Nov 9, 2017 at 0:02
  • @Matifou From that output, you can see that you have another copy of pip in /usr/local/. Try again with full path /usr/bin/pip2 install rpy2
    – user.dz
    Nov 9, 2017 at 0:21
  • Mmh, unfortunately this doesn't help either, still same error message... But indeed, I was 2 pip, with two versions: /usr/bin/pip2 --version pip 8.1.1 from /usr/lib/python2.7/dist-packages (python 2.7) pip2 --version pip 9.0.1 from /home/matifou/.local/lib/python2.7/site-packages (python 2.7) (and wasn't able to auto-upgrade the /usr/bin/pip2 one). Thanks!
    – Matifou
    Nov 9, 2017 at 0:27
  • So it seems my issue is slightly different than the one here, so I opened a new post here: askubuntu.com/questions/975523/…, but happy to award here the bounty if it works (seems not possible to move a bounty)! Thanks!
    – Matifou
    Nov 11, 2017 at 18:51

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

  • Hi. My question was actyually about rpy2 and unroll, and thought it was the same issue while it is not. So I posted a new one: askubuntu.com/questions/975523/… But I gave you the bounty as I think you are hinting to the right issue, of having mixed up the python install. Hopefully you will get a hint to solve my issue? Thanks!
    – Matifou
    Nov 15, 2017 at 2:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.