Python Forum
Cannot import BeautifulSoup4 as bs4 and BeautifulSoup4 not in same directory
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Cannot import BeautifulSoup4 as bs4 and BeautifulSoup4 not in same directory
#1
I have installed BeautifulSoup using pip command and installed successfully.
When I attempted to import it in Python; the following error appears.
>>> from bs4 import BeautifulSoup4
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: cannot import name 'BeautifulSoup4' from 'bs4' (C:\Python37-64\lib\site-packages\bs4\__init__.py)
>>>

I checked my filemanager and see that bs4 and beautifulsoup4 are in separate directories.
C:\Python37-64\Lib\site-packages\bs4
C:\Python37-64\Lib\site-packages\beautifulsoup4-4.7.1.dist-info

I saw in another forum to combine both in the project folder I will be working on. But I haven't created any project yet. Just wanted to get Python set up correctly first.

Thanks
Reply
#2
It's from bs4 import BeautifulSoup
Take a look at Web-Scraping part-1, part2
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Beautifulsoup4 help samuelbachorik 1 1,326 Feb-05-2022, 10:44 PM
Last Post: snippsat
  Python3 + BeautifulSoup4 + lxml (HTML -> CSV) - How to write 3 Columns to MariaDB? BrandonKastning 21 6,712 Mar-23-2020, 05:51 PM
Last Post: ndc85430
  Python3 + BeautifulSoup4 + lxml (HTML -> CSV) - How to loop to next HTML/new CSV Row BrandonKastning 0 2,329 Mar-22-2020, 06:10 AM
Last Post: BrandonKastning
  BeautifulSoup4 plugin help Lathem01 2 1,985 Feb-16-2020, 11:56 AM
Last Post: snippsat
  Python can't import Django and it's in the site-packages directory karkas 3 7,988 Feb-11-2020, 02:59 AM
Last Post: menator01
  BeautifulSoup4, How to get an HTML tag with specific class. Broadsworde 6 10,832 Nov-22-2018, 05:25 PM
Last Post: snippsat
  How to use BeautifulSoup4 with pandas series type of html data? PrateekG 4 4,854 Apr-26-2018, 07:33 AM
Last Post: PrateekG
  What's a good practice project for learning BeautifulSoup4, which has a real use case league55 2 2,690 Jan-27-2018, 11:29 PM
Last Post: league55

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020