skip to Main Content

I am facing a rather minor problem where I am unable to use the Library ‘Beautifulsoup4’. I use VSCode as IDE and use a Venv with Python Version 3.12.2. Everytime I try to run my programm it gives me the error:

ModuleNotFoundError: No module named 'bs4'

To import Beautifoulsoup I use the import command, which even gets recognized and suggested, when trying to type it, by the IDE:

import bs4

At first I have successfully activated my venv in the terminal via:

.venv/scripts/activate

Then I have tried to install the Library via Pip:

pip install beautifulsoup4          

and

pip3 install beautifulsoup4         

After trying to install it via pip I was able to find the Library inside the folder of the "Lib" folder of the venv. But it still did not work. I have tried to uninstall and reinstall it multiple times but it was still not working.

I have already check and see that I was using the right interpreter and I was.

2

Answers


  1. please use

    pip3 install bs4 requests
    

    and then use

    from bs4 import BeautifulSoup
    
    Login or Signup to reply.
    1. Seems like VSCode is trying to run the default python interpreter installed on your system (where package beautifulsoup4 is not installed) instead of particular venv (where you have already installed this package). To tell VSCode to use the particular venv set the python.defaultInterpreterPath option in your .vscode/settings.json file – link
      (see python.terminal.activateEnvironment option too)
    2. Seems like package beautifulsoup4 should be imported as bs4 according to "Quick start" section – from bs4 import ..
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search