perymerdeka
perymerdeka

Reputation: 821

ModuleNotFoundError: No module named 'bs4' but in pip list is already installed

in here try to install beautifulSoup using pip, but the module is not found,

I try to verify python path and pip on my computer here us the result

/Users/macbookairm2/Code/Dev/Fiverr/Scraping/project/AAMUProject/RosterBio/venv/bin/python
venv➜  RosterBio git:(dockerized) ✗ which pip
/Users/macbookairm2/Code/Dev/Fiverr/Scraping/project/AAMUProject/RosterBio/venv/bin/pip
venv➜  RosterBio git:(dockerized) ✗ 

and here is my pip list

 pip list                      
Package                   Version
------------------------- -----------
alembic                   1.14.1
amqp                      5.3.1
annotated-types           0.7.0
anyio                     4.4.0
attrs                     24.2.0
automaton                 3.2.0
autopage                  0.5.2
azure-functions           1.21.3
bcrypt                    4.2.1
beautifulsoup4            4.13.3
cachetools                5.5.2
certifi                   2024.8.30
cffi                      1.17.1
charset-normalizer        3.3.2
click                     8.1.7
cliff                     4.8.0
cmd2                      2.5.11
cryptography              44.0.1
debtcollector             3.0.0
decorator                 5.2.0
dnspython                 2.7.0
dogpile.cache             1.3.4
eventlet                  0.39.0
fastapi                   0.115.8
fasteners                 0.19
futurist                  3.0.0
gnureadline               8.2.13
greenlet                  3.1.1
h11                       0.14.0
httpcore                  1.0.5
httpx                     0.27.2
idna                      3.8
importlib_metadata        8.6.1
iso8601                   2.1.0
Jinja2                    3.1.5
jmespath                  1.0.1
jsonpatch                 1.33
jsonpointer               3.0.0
jsonschema                4.23.0
jsonschema-specifications 2024.10.1
keystoneauth1             5.10.0
keystonemiddleware        10.9.0
kombu                     5.4.2
legacy-cgi                2.6.2
logutils                  0.3.5
magnum                    19.0.0
Mako                      1.3.9
mangum                    0.19.0
markdown-it-py            3.0.0
MarkupSafe                3.0.2
mdurl                     0.1.2
msgpack                   1.1.0
netaddr                   1.3.0
networkx                  3.4.2
numpy                     2.2.3
openstacksdk              4.3.0
os-client-config          2.1.0
os-service-types          1.7.0
osc-lib                   3.2.0
oslo.cache                3.10.1
oslo.concurrency          7.1.0
oslo.config               9.7.1
oslo.context              5.7.1
oslo.db                   17.2.0
oslo.i18n                 6.5.1
oslo.log                  7.1.0
oslo.messaging            16.1.0
oslo.metrics              0.11.0
oslo.middleware           6.3.1
oslo.policy               4.5.1
oslo.reports              3.5.1
oslo.serialization        5.7.0
oslo.service              4.1.0
oslo.upgradecheck         2.5.0
oslo.utils                8.2.0
oslo.versionedobjects     3.6.0
outcome                   1.3.0.post0
packaging                 24.1
pandas                    2.2.3
Paste                     3.10.1
PasteDeploy               3.1.0
pbr                       6.1.1
pecan                     1.5.1
pip                       25.0.1
platformdirs              4.3.6
prettytable               3.14.0
prometheus_client         0.21.1
psutil                    7.0.0
pycadf                    4.0.1
pycparser                 2.22
pydantic                  2.10.6
pydantic_core             2.27.2
pydot                     3.0.4
Pygments                  2.18.0
PyJWT                     2.10.1
pyOpenSSL                 25.0.0
pyparsing                 3.2.1
pyperclip                 1.9.0
PySocks                   1.7.1
python-barbicanclient     7.0.0
python-cinderclient       9.6.0
python-dateutil           2.9.0.post0
python-dotenv             1.0.1
python-glanceclient       4.7.0
python-heatclient         4.1.0
python-keystoneclient     5.5.0
python-neutronclient      11.4.0
python-novaclient         18.8.0
python-octaviaclient      3.9.0
python-openstackclient    7.3.1
python-swiftclient        4.6.0
pytz                      2024.2
PyYAML                    6.0.2
referencing               0.36.2
repoze.lru                0.7
requests                  2.32.3
requestsexceptions        1.4.0
rfc3986                   2.0.0
rich                      13.8.0
Routes                    2.5.1
rpds-py                   0.23.1
selenium                  4.25.0
setuptools                75.8.0
shellingham               1.5.4
simplegeneric             0.8.1
six                       1.16.0
sniffio                   1.3.1
sortedcontainers          2.4.0
soupsieve                 2.6
SQLAlchemy                2.0.38
starlette                 0.45.3
statsd                    4.0.1
stevedore                 5.4.1
taskflow                  5.11.0
tenacity                  9.0.0
testresources             2.0.1
testscenarios             0.5.0
testtools                 2.7.2
trio                      0.26.2
trio-websocket            0.11.1
typer                     0.12.5
typing_extensions         4.12.2
tzdata                    2024.2
urllib3                   2.2.3
uvicorn                   0.34.0
vine                      5.1.0
warlock                   2.0.1
wcwidth                   0.2.13
webdriver-manager         4.0.2
WebOb                     1.8.9
websocket-client          1.8.0
Werkzeug                  3.1.3
wrapt                     1.17.2
WSME                      0.12.1
wsproto                   1.2.0
yappi                     1.6.10
zipp                      3.21.0
venv➜  RosterBio git:(dockerized)

the beautifulsoup4 is already install on my computer but the module is still not found

uvicorn manage:app --host 0.0.0.0 --port 8000 --reload 
INFO:     Will watch for changes in these directories: ['/Users/macbookairm2/Code/Dev/Fiverr/Scraping/nivyschedulescraper/AAMUProject/RosterBio/src']
INFO:     Uvicorn running on http://0.0.0.0:8000 (Press CTRL+C to quit)
INFO:     Started reloader process [62922] using WatchFiles
Process SpawnProcess-1:
Traceback (most recent call last):
  File "/opt/homebrew/Cellar/[email protected]/3.12.9/Frameworks/Python.framework/Versions/3.12/lib/python3.12/multiprocessing/process.py", line 314, in _bootstrap
    self.run()
  File "/opt/homebrew/Cellar/[email protected]/3.12.9/Frameworks/Python.framework/Versions/3.12/lib/python3.12/multiprocessing/process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
  File "/opt/homebrew/lib/python3.12/site-packages/uvicorn/_subprocess.py", line 80, in subprocess_started
    target(sockets=sockets)
  File "/opt/homebrew/lib/python3.12/site-packages/uvicorn/server.py", line 65, in run
    return asyncio.run(self.serve(sockets=sockets))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/[email protected]/3.12.9/Frameworks/Python.framework/Versions/3.12/lib/python3.12/asyncio/runners.py", line 195, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/[email protected]/3.12.9/Frameworks/Python.framework/Versions/3.12/lib/python3.12/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "uvloop/loop.pyx", line 1518, in uvloop.loop.Loop.run_until_complete
  File "/opt/homebrew/lib/python3.12/site-packages/uvicorn/server.py", line 69, in serve
    await self._serve(sockets)
  File "/opt/homebrew/lib/python3.12/site-packages/uvicorn/server.py", line 76, in _serve
    config.load()
  File "/opt/homebrew/lib/python3.12/site-packages/uvicorn/config.py", line 434, in load
    self.loaded_app = import_from_string(self.app)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.12/site-packages/uvicorn/importer.py", line 22, in import_from_string
    raise exc from None
  File "/opt/homebrew/lib/python3.12/site-packages/uvicorn/importer.py", line 19, in import_from_string
    module = importlib.import_module(module_str)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/[email protected]/3.12.9/Frameworks/Python.framework/Versions/3.12/lib/python3.12/importlib/__init__.py", line 90, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 999, in exec_module
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "/Users/macbookairm2/Code/Dev/Fiverr/Scraping/nivyschedulescraper/AAMUProject/RosterBio/src/manage.py", line 2, in <module>
    from core import create_app
  File "/Users/macbookairm2/Code/Dev/Fiverr/Scraping/nivyschedulescraper/AAMUProject/RosterBio/src/core/__init__.py", line 2, in <module>
    from api.v1.routers.rosterbio import router
  File "/Users/macbookairm2/Code/Dev/Fiverr/Scraping/nivyschedulescraper/AAMUProject/RosterBio/src/api/v1/routers/rosterbio.py", line 4, in <module>
    from services.rosterbio_service import RosterBioService
  File "/Users/macbookairm2/Code/Dev/Fiverr/Scraping/nivyschedulescraper/AAMUProject/RosterBio/src/services/rosterbio_service.py", line 5, in <module>
    from modules.spider.rosterbio import AamuSportRosterSpider
  File "/Users/macbookairm2/Code/Dev/Fiverr/Scraping/nivyschedulescraper/AAMUProject/RosterBio/src/modules/spider/rosterbio.py", line 3, in <module>
    from bs4 import BeautifulSoup
ModuleNotFoundError: No module named 'bs4'

anyone can help?, form beautifulsoup I refer to this docs Thanks!

Upvotes: 0

Views: 33

Answers (1)

Ninja-Flex6969
Ninja-Flex6969

Reputation: 107

There is a conflict between your virtual env and your host. Inside your virtual env install bs4. Then try to import it. While having the virtual env active of course.

Or do the opposite inside your host install bs4

Upvotes: 1

Related Questions