Python Forum

Full Version: ImportError: cannot import name 'beautifulsoup'
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi guys! Just new here.

I'm using Windows-7, the latest Python 3.7 and the latest Beautifulsoup4.6 but still getting those error. Tried a variety of mixing things up, searching the web, youtube tutorials but still getting that error.

I mean it's working fine when I try to run to check for no errors using Python IDLE. But as we know, that's already inside Python. I usually use Sublime and Windows Powershell to run things.

Hope I had put all the information and thanks in advance for the help.

Oh, and btw, still getting the same error using Mac.
post your code in python tags. Post the full traceback you get - in error tags. how did you install BeautifulSoup? Do you have more than one python installation?
# Test that python use 3.7
C:\>python -c "import sys; print(sys.executable)"

# Test that pip use 3.7
C:\>pip -V
pip 10.0.1 from c:\python37\lib\site-packages\pip (python 3.7)

# Install
C:\>pip install -U beautifulsoup4
Requirement already up-to-date: beautifulsoup4 in c:\python37\lib\site-packages (4.6.0)

# Test that it work
Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:06:47) [MSC v.1914 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import bs4
>>> bs4.__version__

>>> # Normal import 
>>> from bs4 import BeautifulSoup
>>> soup = BeautifulSoup('html', 'html.parser') # Or 'lxml' for faster parser
Python 3.6/3.7 and pip installation under Windows
Follow this then should all be working,if use Editors eg VS Code, PyCharm ...ect.
So most there config choice of which interpreter point to 3.7.
Apology for the late response. The forum notification ends up on my spam email folder.
Used Windows Powershell to install beautifulsoup.
python -m pip install bs4
The code is just a practice code from a video lesson and just had a simple html code inside the same .py sheet. Nothing fancy, just trying to output the same html by calling
soup = beautifulsoup(html, "html.parser") 
Here's the error.
Traceback (most recent call last): File "" line 1, in <module> from bs4 import beautifulsoup ImportError: cannot import name 'beautifulsoup'
It should be BeautifulSoup, not beautifulsoup
Do I need an venv for this to work? Coz to my surprise scrapy needs a new folder to create it's venv in order for it to run. Just also asking if I might be missing that part? Thanks for the answer buran, will try that later.
you can make virtual environment and it's even recommended, but not required