No module named 'beautifulsoup4' in python3
12,951
Solution 1
Only install BeautifulSoup4
instead of bs4
and BeautifulSoup
then,
do this:
from bs4 import BeautifulSoup
Solution 2
Try to replace from beautifulsoup4 import BeautifulSoup in
from bs4 import BeautifulSoup
It works with me.
Solution 3
I would do this for a work around:
All of this under your created virtual environment
$ wget https://pypi.python.org/pypi/beautifulsoup4
$ pip3 install beautifulsoup4-4.6.0-py3-none-any.whl
$ pip3 freeze |grep beautifulsoup4
$ python3
>>> from bs4 import BeautifulSoup
Related videos on Youtube
Author by
ishandutta2007
Former Amazon, Former Microsoft Engineer For details, https://www.linkedin.com/in/ishandutta2007/
Updated on September 15, 2022Comments
-
ishandutta2007 over 1 year
$ virtualenv test $ source test/bin/activate $ pip3 install beautifulsoup4
Now the script test.py
import urllib.request import sys import unittest, time, re import requests from bs4 import BeautifulSoup class Sel(unittest.TestCase): def setUp(self): self.base_url = "file:///Users/ishandutta2007/Desktop/cars/cars-price-list.html" def test_sel(self): with urllib.request.urlopen(self.base_url) as url: html_source = url.read() data = html_source#.encode('utf-8') parsed_html = BeautifulSoup(data, 'html.parser') if __name__ == "__main__": unittest.main()
when I run
$python3 test.py
File "test.py", line 6, in from bs4 import BeautifulSoup ModuleNotFoundError: No module named 'bs4'
then tried with
from beautifulsoup4 import BeautifulSoup
File "test.py", line 6, in from beautifulsoup4 import BeautifulSoup ModuleNotFoundError: No module named 'beautifulsoup4'
requirements clearly shows both
$ pip3 freeze > requirements.txt $ cat requirements.txt beautifulsoup4==4.6.0 certifi==2018.1.18 chardet==3.0.4 idna==2.6 requests==2.18.4 urllib3==1.22
-
Abhijeetk431replace
beautifulsoup4
withbs4
-
-
Eric Aya over 2 yearsThis has already been mentioned in the other answers.