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,543
  • Looks like there's some python 2.7 code in the install script, because there are no parentheses in the print statement. – NeoTheThird Feb 09 '17 at 18:54
  • Can you try with the -H parameter for sudo as suggested in the warning message ? – albert j Feb 09 '17 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 – huehuehuehuehuehuehuehuehuehue Feb 09 '17 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... – huehuehuehuehuehuehuehuehuehue Feb 11 '17 at 10:59
  • Same issue, on Ubuntu 16.04 with Python 2.7.12. This post (https://stackoverflow.com/questions/35991403/python-pip-install-gives-command-python-setup-py-egg-info-failed-with-error-c) has a bunch of answers but none of them work – Matifou Nov 07 '17 at 20:19
  • @Matifou how did you try to install it? I just tested on a fresh set up 16.04.3 VM and it works perfectly (besides the install wants sudo to function) – Videonauth Nov 07 '17 at 21:14
  • @Videonauth sorry should have mentioned my problem is about unroll/rpy2! Tried to install with pip install unroll, or pip install rpy2==2.2.7, both fail with same error message as in post above. (and indeed BeautifulSoup works with sudo). None of pip install --upgrade setuptools, pip install ez_setup or easy_install -U setuptools did help. Any idea? Thaaaanks! – Matifou Nov 07 '17 at 23:14
  • You can try to use the Python3 version and download it with Pip3 – Paulo Botelho Nov 08 '17 at 08:33
  • Could you please post text files, dialogue messages, and program output listings as text, not as images? To achieve the latter two you can either 1) select, copy & paste the dialogue text or terminal content or 2) save the program output to a file and use that. Longer listings (the editor will tell you what's too long) should be uploaded to a pastie service and linked to in the question. Thanks. – David Foerster Nov 09 '17 at 19:05
  • Could you please [edit] your question to include the output of sudo which python pip | xargs -rd '\n' readlink -f, sudo python --version and sudo pip --version? (sudo may be relevant here because root may have a different PATH.) Thanks. – David Foerster Nov 09 '17 at 19:07
  • @Matifou What does pip --version report? – muru Nov 10 '17 at 05:36
  • Thanks @DavidFoerster. I'm not the original author of post (should have maybe started another post... but thought was same issue, sorry) . Here is the output: sudo which python pip | xargs -rd '\n' readlink -f gives /usr/bin/python2.7 and /usr/local/bin/pip. sudo python --version gives Python 2.7.12 and sudo pip --version leads to pip 9.0.1 from /home/matifou/.local/lib/python2.7/site-packages (python 2.7). See also output below user.dz post for pip versions. Overall errorinstalling is *Command "python setup.py egg_info" failed with error code 1 * – Matifou Nov 10 '17 at 18:08
  • @Matifou: Your Python/Pip executables and library paths are completely messed up. Please open a new question and include as much information about your various Python and Pip installations as possible. Thanks. – David Foerster Nov 10 '17 at 21:29
  • So @DavidFoerster, it seems my issue is slightly different than the one here, so I opened a new post here: https://askubuntu.com/questions/975523/pipinstall-gives-command-python-setup-py-egg-info-failed-with-error-code-1, but happy to award here the bounty if it works (seems not possible to move a bounty)! Thanks! – Matifou Nov 11 '17 at 18:50
  • So I started a new bounty at https://askubuntu.com/questions/975523/pipinstall-gives-command-python-setup-py-egg-info-failed-with-error-code-1, happy to have your feedback @DavidFoerster, thanks! – Matifou Nov 16 '17 at 18:18
  • Hi @DavidFoerster, was wondering whether you had any hints on the "messed-up paths" in the new post https://askubuntu.com/questions/975523/pipinstall-gives-command-python-setup-py-egg-info-failed-with-error-code-1?noredirect=1#comment1570565_975523? Thanks! – Matifou Nov 19 '17 at 18:49

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

  • 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: https://askubuntu.com/questions/975523/pipinstall-gives-command-python-setup-py-egg-info-failed-with-error-code-1 thanks! – Matifou Nov 13 '17 at 21:30
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,295
  • 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 09 '17 at 00: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 09 '17 at 00: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 09 '17 at 00:27
  • So it seems my issue is slightly different than the one here, so I opened a new post here: https://askubuntu.com/questions/975523/pipinstall-gives-command-python-setup-py-egg-info-failed-with-error-code-1, but happy to award here the bounty if it works (seems not possible to move a bounty)! Thanks! – Matifou Nov 11 '17 at 18:51
-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,800
Diffeo
  • 51
  • 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: https://askubuntu.com/questions/975523/pipinstall-gives-command-python-setup-py-egg-info-failed-with-error-code-1 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 '17 at 02:28