{ Where’s BeautifulSoup in Anaconda’s Python? }

Visit link
03 Feb / 2014
Author: cecilia Tags: , Comments: 6

Bookmark and Share

If the title of the post sounds cryptic, then you’re not a pythonista, in which case you can happily ignore the next 3 minutes of geek talk! For anyone else met with an error when executing “import BeautifulSoup from BeautifulSoup” (especially running Anaconda’s version of Python), here’s a handy tip.

Running 32-bit Ubuntu 12.04, I asked for “python” in terminal and was met with
Python 2.7.6 |Anaconda 1.8.0 (32-bit)| (default, Nov 11 2013, 10:47:19)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-52)] on linux2

Good, I am running the right flavour of python under Anaconda 1.8.0, so next up is to import BeautifulSoup. (For background information, I was following this tutorial on web scraping).

ImportError: No module named BeautifulSoup

Okay, maybe BeautifulSoup isn’t a standard package? Back to terminal, I searched for Anaconda’s linked packages:
cecilialiao@ubuntu:~$ conda list
# packages in environment at /home/x/anaconda:
# Warning: subprocess call to pip failed
_license 1.1 py27_0
anaconda 1.8.0 np17py27_0
apptools 4.2.0 py27_0
astropy 0.2.5 np17py27_0
atom 0.3.4 py27_0
beautiful-soup 4.3.1 py27_0
binstar 0.3.1 py27_1

BeautifulSoup is blatantly there, so why the import error?

Turns out that the latest version of BeautifulSoup (as of writing) is no longer called BeautifulSoup, but instead “bs4″ (all lower cap). So, to use the library, you run the following…

from bs4 import BeautifulSoup

… and you’re all set to go.

All this is pretty obvious if I knew to go to BeautifulSoup’s documentation in the first place, or even Wikipedia’s entry on BeautifulSoup, for the simple command. As it happened, though, trying to learn linux and python at the same time can lead one to over an hour of fruitless Google searches. I hope this helps beginners out there scratching their heads when trying to follow an older webscraping tutorial on using BeautifulSoup!

(Image courtesy of Xavi Villalvilla.)


  • Brian Carpio 01 Mar 2014

    Hey thanks for referencing my website!

  • Paul 01 Jun 2014

    I found that a little strange/confusing as well.
    As you found out, this is how the module is imported for every BS package, whether the Anaconda/binstar version or regular python.

  • Kaspar 06 Jun 2014

    Thanks so much for the info I couldn’t get Beutifulsoup to work at all with conda.

  • macross 13 Nov 2014

    You just saved me a whole afternoon! Thanks!

  • El Duderino 29 Mar 2015

    Thank you random person I found while Googling this problem. You probably saved me at least 30 minutes. And now that I have an extra 30 minutes to spare I’m going to play a quick game of chess. Keep on keeping on :)

  • Bill 02 Aug 2015

    Thanks, this helps. I installed beautiful-soup 4.3.2 using condo. But I still get the following error when I try to import bs4:

    from bs4 import BeautifulSoup
    ImportError: No module named bs4

    Any idea what am I doing wrong?

/// Leave a Reply