Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ModuleNotFoundError: No module named 'bs4'

I'm still super new to coding! Trying to learn from online tutorials, but I seem to be stuck on the first step! I think I installed bs4, but it's not showing up in python3, is it installed in the wrong place?

robbie$ sudo -H pip install bs4
Requirement already satisfied: bs4 in /Library/Python/2.7/site-packages
Requirement already satisfied: beautifulsoup4 in /Library/Python/2.7/site-packages (from bs4)
Robbies-MBP:~ robbie$ python3
Python 3.6.1 (v3.6.1:69c0db5050, Mar 21 2017, 01:21:04) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import bs4
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'bs4'

Any help would be greatly appreciated :)

like image 983
robbie777 Avatar asked Apr 03 '17 18:04

robbie777


People also ask

How do I import a bs4 module into Python?

The Python "ModuleNotFoundError: No module named 'bs4'" occurs when we forget to install the beautifulsoup4 module before importing it or install it in an incorrect environment. To solve the error, install the module by running the pip install beautifulsoup4 command.

What is bs4 in Python?

Beautiful Soup is a Python library for pulling data out of HTML and XML files. It works with your favorite parser to provide idiomatic ways of navigating, searching, and modifying the parse tree. It commonly saves programmers hours or days of work.

How do I import from BeautifulSoup?

To use beautiful soup, you need to install it: $ pip install beautifulsoup4 . Beautiful Soup also relies on a parser, the default is lxml . You may already have it, but you should check (open IDLE and attempt to import lxml). If not, do: $ pip install lxml or $ apt-get install python-lxml .


1 Answers

Requirement already satisfied: bs4 in /Library/Python/2.7/site-packages

Python 3.6.1 (v3.6.1:69c0db5050, Mar 21 2017, 01:21:04)

You have the module installed for Python 2.7, however you're using and trying to import it with Python 3.6.

You have to use pip3 like you use python3.

like image 56
vallentin Avatar answered Sep 23 '22 03:09

vallentin