Take the 2-minute tour ×

As the Beautiful Soup documentation says:

If all else fails, the license for Beautiful Soup allows you to package the entire library with your application. You can download the tarball, copy its bs4 directory into your application’s codebase, and use Beautiful Soup without installing it at all.

This is exactly what I want, and what I've done... up to the point of using it in my code. I don't know how to import Beautiful Soup 4. Unlike v3, there's no standalone BeautifulSoup.py, just that bs4 directory with a bunch of python scripts. Does anyone have an example of how to use Beautiful Soup 4 when you have the source code in your project?

share|improve this question
just be aware that some of the things that BeautifulSoup depends on may or may not be present... (e.g. if you wanted to use lxml) –  Jeff Tratner Jun 12 '12 at 19:44
add comment

1 Answer

up vote 6 down vote accepted

That 'bunch of python scripts' is called a python package; there should be a __init__.py file in there somewhere. Together they form a coherent whole, a namespaced set of modules.

You can just import the BeautifulSoup class from the bs4 package:

from bs4 import BeautifulSoup

See the documentation for more info.

share|improve this answer
Thanks for helping a python n00b. –  kevlar1818 Jun 12 '12 at 19:06
add comment

Your Answer


