5

I am using Ubuntu 14.04 64 bit Operating System .

I installed Beautiful Soup 4 using this command :

sudo apt-get install python-bs4

With Python 2.7.6 , I had no difficulty importing the bs4 module. But when I used Python 3.4.0 it showed me this error.

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

I also tried to install it using pip.

sudo pip install beautifulsoup4

But again it didn't worked with Python 3.4.0.

Right now I have uninstalled pip and also uninstalled Beautiful Soup 4

sudo apt-get remove python-bs4
sudo apt-get remove python-pip

What should I do next to properly install Beautiful Soup 4 for both Python 2.7.6 and Python 3.4.0 ??

11

In all currently supported versions of Ubuntu open the terminal and run:

sudo apt-get install python3-bs4

python3-bs4 is an error-tolerant HTML parser for Python 3. You can see from this that there are two different packages: python-bs4 (for Python 2.x) and python3-bs4 (for Python 3.x), and to prevent you from getting confused there are also two different Integrated Development Environments for Python: IDLE and IDLE 3 to run them in.

  • Thank You . I just installed it using the command that you provided and it is working !! I also installed Beautiful Soup 4 for Python 2.7.6 using the old command. Now it is working with both the Python versions . – sud_the_devil Aug 12 '14 at 11:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.