Background & What I did: I'm writing a webpage content extractor, and realized the need to install BeautifulSoup4 to better parse my HTML file. On my Ubuntu 13.04 machine, I have both Python2.7(system default) and Python3.3.1 installed. After a few failures with both pip
and easy_install
due to the "SSL certificate" issue, I got to finally install BeautifulSoup4 using easy_install on my last try.
But: It seems that easy_install
installed BS4 into the Python2.7 directory(/usr/local/lib/python2.7/dist-packages
) in my system, as you can tell from the information below:
Searching for beautifulsoup4
Reading http://pypi.python.org/simple/beautifulsoup4/
Best match: beautifulsoup4 4.2.1
Downloading https://pypi.python.org/packages/source/b/beautifulsoup4/beautifulsoup4-4.2.1.tar.gz#md5=91ea70ce16a5f1f43e58f2ef05651679
Processing beautifulsoup4-4.2.1.tar.gz
Writing /tmp/easy_install-OLXNjV/beautifulsoup4-4.2.1/setup.cfg
Running beautifulsoup4-4.2.1/setup.py -q bdist_egg --dist-dir /tmp/easy_install-OLXNjV/beautifulsoup4-4.2.1/egg-dist-tmp-SpupH8
zip_safe flag not set; analyzing archive contents...
Adding beautifulsoup4 4.2.1 to easy-install.pth file
Installed /usr/local/lib/python2.7/dist-packages/beautifulsoup4-4.2.1-py2.7.egg
Right now I'm able to import BS4 in Python2.7, but not in Python3.3, with this error message:
>>> import bs4
Traceback (most recent call last):
File "<pyshell#8>", line 1, in <module>
import bs4
ImportError: No module named 'bs4'
Question: Should I add this Python2.7 directory to my Python3.3 library directory? (I worry about future conflict of different versions of a same module due to this shared library path) or should I uninstall BS4 and try it again with pip
so maybe it'll install BS4 in Python3.3 directory? (right now this got returned when I try to install BS4 again using pip
: Requirement already satisfied (use --upgrade to upgrade): beautifulsoup4 in ./beautifulsoup4-4.2.1-py2.7.egg
) Other general pointers about solving this problem will also be appreciated. Thank you!
According to the section Download Beautiful Soup
on the official homepage, you can install the python-beautifulsoup4
package on Ubuntu 13.04.
Try this to prevent the conflict between Python 2.7 and 3.3. Before you do that though, I'd recommend removing the Beautiful Soup egg to avoid a potential version conflict.