ImportError: cannot import name BeatifulSoup - python

In my program i used from bs4 import BeatifulSoup, and i get the error:
Traceback (most recent call last):
File "D:\Noahs program\python black hat\retrievescreenshot.py", line 2, in <module>
from bs4 import BeatifulSoup
ImportError: cannot import name BeatifulSoup
I installed bs4 from the command line with pip.exe from python 2.7.15.
pip install bs4
I have tried pip install beautifulsoup4 and it said installation allready satisfied.

pip install beautifulsoup4
then you will be able to import it

You have a typo in your import... It should be:
from bs4 import BeautifulSoup #<-- not BeatifulSoup

Related

ModuleNotFoundError with a python requests library

Is anyone else receiving a moduleNotFoundError with their requests library? Not sure why this is happening. The library is installed as well which is even more confusing.
import csv
from datetime import datetime
import requests
from bs4 import BeautifulSoup
and the resulting error was this:
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
Cell In [1], line 4
2 import csv
3 from datetime import datetime
----> 4 import requests
5 from bs4 import BeautifulSoup
ModuleNotFoundError: No module named 'requests'
when i run pip freeze I can confirm I have requests installed as well, see below:
Screenshot from my terminal
I have requests version requests==2.28.1
Most likely, you don't have the requests module installed. Run the following command:
pip install requests to install the package.
corrected the error by referencing this question (i didnt see it when I first searched)
running sudo pip3 install requests and it recognized the library now.

BeautifulSoup problem using 'from bs4 import BeautifulSoup' not working on Python 3.7 with mac

I installed BeautifulSoup with my terminal, and when i got to Python 3.7.0 shell i cannot import using 'from bs4 import BeautifulSoup'
like this:
> >> from bs4 import BeautifulSoup Traceback (most recent call last): File "<pyshell#26>", line 1, in <module>
> from bs4 import BeautifulSoup ModuleNotFoundError: No module named 'bs4'
Please help!
If you are working with the global Python3 that's installed on the whole mac operating system, you can see which libraries you have currently installed by running pip3 freeze:
> pip3 freeze
certifi==2018.4.16
....
Then install beautifulsoup4 and verify your new library is available again with pip3 freeze:
> pip3 install beautifulsoup4
> pip3 freeze
beautifulsoup4==4.6.3
certifi==2018.4.16

Python doesn't find packages that are installed with Conda

I installed anaconda to C:\Users\chris\Anaconda3. When I type conda list it verifies that I have BeautifulSoup4 installed.
However when I start C:\Users\chris\Anaconda3\python.exe and try to import BeautifulSoup it doesn't work:
>>> import BeautifulSoup
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'BeautifulSoup'
When I'm in the Anaconda Navigator it also lists the package but when I try to start base(root)/Open with python I can't import my package. Neither can Spyder that I installed.
What do I have to do, to fix this?
i'm sorry but maybe you need to import in this way ?
from bs4 import BeautifulSoup
docs

No module named BeautifulSoup (but it should be installed) [duplicate]

This question already has answers here:
ImportError: No module named BeautifulSoup
(8 answers)
Closed 3 years ago.
I downloaded BeautifulSoup.
Then I upgraded pip:
pip install --upgrade pip
Then, installed BS:
pip install beautifulsoup4
It seems like everything worked fine, but now when I run these three lines of code:
from BeautifulSoup import BeautifulSoup
import urllib2
import csv
I get this error.
Traceback (most recent call last):
File
"C:\Users\rshuell001.spyder2\temp.py", line 1, in
from BeautifulSoup import BeautifulSoup ImportError: No module named BeautifulSoup
I'm using Anaconda-Spyder
What am I doing wrong?
I think it should be: from bs4 import BeautifulSoup.

Trouble using BeautifulSoup Python 3

I keep on getting a traceback whether I use bs4, beautifulsoup4 or BeautifulSoup
Traceback (most recent call last):
File "<pyshell#3>", line 1, in <module>
from BeautifulSoup import BeautifulSoup
ImportError: No module named 'BeautifulSoup'
On terminal I get
Peters-Mac-mini:~ admin$ pip install beautifulsoup4
Requirement already satisfied (use --upgrade to upgrade): beautifulsoup4 in /Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site-packages
Cleaning up...
This is the first time that I am attempting to use BeautifulSoup, but I have never experienced this error with other installations. Don't know how to get out of it! I have not seen this problem amongst the Stack Overflow posts.
You need to import from bs4, not BeautifulSoup.
from bs4 import BeautifulSoup
Module names is not always the same in each versions.
This would help.
from bs4 import BeautifulSoup
If you a want cross platform style of importing BeautifulSoup
You could do like this:
try:
from bs4 import BeautifulSoup
except ImportError:
from BeautifulSoup import BeautifulSoup

Categories