Cooby Booby
Cooby Booby

Reputation: 303

Cannot install BeautifulSoup for python 3.6

I have spent the past 45 minutes hopelessly trying to run:

from bs4 import BeautifulSoup

But to no avail. I have tried the commands:

python -m pip install beautifulsoup4

where it says:

Requirement already satisfied: beautifulsoup4 in c:\python27\lib\site-packages

I have tried:

pip3 install beautifulsoup4

where it says the same.

I have tried:

pip install beautifulsoup4

Same thing.

I have looked all over stackoverflow, youtube, I am driving myself insane trying to figure this out. I have no idea what to do, please help me.

When I try to run my program main.py with the following code:

from bs4 import BeautifulSoup

With py -3 main.py, I get the error:

ModuleNotFoundError: No module named 'bs4'

Please please please please help me.

I have tried the method proposed at BeautifulSoup4 can't be installed in python3.5 on Windows7 but to no avail.

Upvotes: 16

Views: 47041

Answers (8)

AlanSTACK
AlanSTACK

Reputation: 6075

Just install this instead: https://anaconda.org/ (This is what we use at work to manage imports).

It's basically Python with the top 100 modules all installed. The only downside is size (300 MB).

Upvotes: 1

Akshay
Akshay

Reputation: 39

Just install:

pip3 install bs4 --user

Import in code:

from bs4 import BeautifulSoup
import requests

res = requests.get(url)
soup = BeautifulSoup(res.content,"html.parser")

Upvotes: 1

Thanks noobninja,

As for extending Python 3.8 to BeautifulSoup4, only using ANACONDA worked with me (using MAC OS).

  1. Download Anaconda for Mac OS (more than 2 GB)
  2. In terminal: test Anaconda installation:

    $ conda list

  3. $ conda install beautifulsoup4
  4. Run Python3 shell
  5. type : from bs4 import BeautifulSoup

No error message !

Upvotes: 0

user3325126
user3325126

Reputation: 1384

I was getting this same error on a mac and the problem stemmed from using Python 2.7.10 when I thought I was using 3.7.

python test.py

File "test.py", line 1, in <module>
    from bs4 import BeautifulSoup
ImportError: No module named bs4

However when I was explicit about what python version I wanted to use everything worked. So on the terminal use python and then your version number. Example my version is 3.7:

python3.7 test.py

Upvotes: 0

xandra
xandra

Reputation: 51

I went through something similar but managed to install BeautifulSoup4. I tried running the commands suggested but none of it worked. So here's what I did.

On the command prompt, I decided to try running the commands on the python scripts directory

cd C:\Users\User\AppData\Local\Programs\Python\Python36-32\Scripts

then

pip3 install BeautifulSoup4

You should see something that says

Collecting BeautifulSoup4
 Downloading beautifulsoup4-4.6.0-py3-none-any.whl (86kB)
   100% |████████████████████████████████| 92kB 6.7kB/s
Installing collected packages: BeautifulSoup4
Successfully installed BeautifulSoup4-4.6.0

Hope this helps.

Upvotes: 5

Darshan
Darshan

Reputation: 183

Now there is beautifulsoup4 for Python 3.6. It's the same, am using it this way on my webcrawl project.

Just add the beautifulsoup4 module to the project. Then try the line

from bs4 import BeautifulSoup

Upvotes: 18

shahin
shahin

Reputation: 3655

As of now the module is not getting loaded to python3.6 Try This

python3.6 -m pip install beautifulsoup4

Upvotes: 13

Muhamad Sohaib Arif
Muhamad Sohaib Arif

Reputation: 154

The problem is that while it installed beautifulsoup4 and several libraries are not supported on Python 3.6 at the moment.

You have two options. You can either use a virtual environment like Anaconda or virtualenv as Alan suggested. Here you will make an environment and set the python version to 3.5

The other option is to uninstall python 3.6 and install 3.5 and then beautifulsoup4

Upvotes: 0

Related Questions