Whenever I import Beautiful soup it infinitely asks to enter a number

Viewed 52

Quite a simple problem I'm probably just doing something wrong but: Even if I just put the import and nothing else like this:

from bs4 import BeautifulSoup

It automatically infinitely asks for this prompt:

Output: Enter a number:

Edit: I am running the same file. Entire program

Any suggestions?

Edit: I got a solution thanks to the comments, there was a duplicate bs4 folder in the same folder as the file.

2 Answers

You have created a bs4 folder and the code might be imported from that folder instead of the original Beautiful Soup module.

May be this is causing due to your background open files. First make sure you had installed bs4 successfully on your device. If not then install by running "pip install beautifulsoup4" on your cmd.After that you close your all open files in Pycharm and reopen IDE. Then try

        from bs4 import BeautifulSoup
        import requests
        url = " "#pass url
        req = requests.get(url)
        soup = BeautifulSoup(req.text, 
        "html.parser")
        print(soup.title)

Hope it will work

Related