Error importing BeautifulSoup – Conflict with Python version

Issue

I installed BeautifulSoup with the command:

sudo easy_install BeautifulSoup4

I got the message:

Searching for BeautifulSoup4
Best match: beautifulsoup4 4.1.3
Processing beautifulsoup4-4.1.3-py2.6.egg
beautifulsoup4 4.1.3 is already the active version in easy-install.pth

Using /Library/Python/2.6/site-packages/beautifulsoup4-4.1.3-py2.6.egg
Processing dependencies for BeautifulSoup4
Finished processing dependencies for BeautifulSoup4

I’m trying to import the BeautifulSoup lib.

>>> from BeautifulSoup import BeautifulSoup
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named BeautifulSoup

or:

>>> from bs4 import BeautifulSoup
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named bs4

My Python version is:

python --version
Python 2.7.3

EDIT

I understand that:

Using /Library/Python/2.6/site-packages/beautifulsoup4-4.1.3-py2.6.egg

Could mean that there is a conflict between the versions of Python

How can I have this module registered? Thanks

Solution

After some research I discovered that this solve the issue:

pip uninstall BeautifulSoup4

will uninstall the package that is in:

/Library/Python/2.6/site-packages/

And:

easy_install-2.7 BeautifulSoup4

will successfully install the package in:

/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/

I’ve checked the process also with some other packages having the same issues and it works.

Answered By – maxdangelo

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published