$ 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
Only install BeautifulSoup4
instead of bs4
and BeautifulSoup
then,
do this:
from bs4 import BeautifulSoup
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With