Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
I have BeautifulSoup instaled
#1
when I try to run a piece of script with this in it      ( from bs4 import BeautifulSoup) Sad

I get this error:      ImportError: No module named bs4 Huh
I have it installed see:

c:\Python2.7>pip install beautifulsoup4
Requirement already satisfied (use --upgrade to upgrade): beautifulsoup4 in c:\p
ython3.5\lib\site-packages

Why can't I make this work. It will not run in 2.7 or 3.5?
Thank you
P.S. I have made My first email scraper, all my own code. Thank you all for your help.
Reply
#2
try
pip install bs4
Recommended Tutorials:
Reply
#3
Thank you
but I try that does not work:

c:\Python3.5>pip install bs4
Requirement already satisfied (use --upgrade to upgrade): bs4 in c:\python3.5\li
b\site-packages
Requirement already satisfied (use --upgrade to upgrade): beautifulsoup4 in c:\p
ython3.5\lib\site-packages (from bs4)

c:\Python3.5>
Reply
#4
try pip install bs4 --upgrade
Recommended Tutorials:
Reply
#5
I did that too:

c:\Python3.5> pip install bs4 --upgrade
Requirement already up-to-date: bs4 in c:\python3.5\lib\site-packages
Requirement already up-to-date: beautifulsoup4 in c:\python3.5\lib\site-packages
(from bs4)
Reply
#6
If you want to install in to Python2.7,navigate to Scripts folder(pip is placed here).
Output:
C:\Python27\Scripts>pip install beautifulsoup4
Then it use pip for Python2.7 and install to 2.7


Quote:Requirement already up-to-date: bs4 in c:\python3.5\lib\site-packages
Then it should work in Python 3.5?
Test it's 3.5 for you.
C:\>python
Python 3.4.2 (v3.4.2:ab2c023a9432, Oct  6 2014, 22:15:05) [MSC v.1600 32 bit (Intel)] on win32
>>> from bs4 import BeautifulSoup
>>> soup = BeautifulSoup('<p>Hello</p>', 'html.parser')
>>> soup.find('p').text
'Hello'
Reply
#7
Will you tell what I just did, it worked.
How did that scrip make it work? Smile
Reply
#8
pip is designed to run for one version of python only.

What happened is that when you run pip without a qualifier (path),
it will use the system default python which is set up as an environment variable, or is in your path.

When you switch to the scripts directory, you have the local copy of pip that is tied to the
version of python containing that (scripts) directory, so it will install for that version
Reply
#9
(Nov-03-2016, 04:02 PM)Blue Dog Wrote: How did that scrip make it work?
Maybe you had wrong import before.
You can look at tutorials i have here.
Reply
#10
I need to install bs4 in python 2.7.
where do I get the 2.7 file at?
Reply


Forum Jump:

User Panel Messages

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