ImportError: No Module Named bs4 (BeautifulSoup)

I work in Python and use Flask. When I run my main Python file on my computer, it works fine, but when I activate venv and run the Python Flask file in the terminal, it says that my main Python file has "No Module Named bs4". Any comments or tips are appreciated.

+112
python flask beautifulsoup importerror
Aug 02 '12 at 18:47
source share
9 answers

Activate virtualenv and then install BeautifulSoup4:

$ pip install BeautifulSoup4 

When you installed bs4 with easy_install , you installed it on a system scale. This way your system python can import it, but not your virtual python. If you do not need bs4 to be installed in your python path, delete it and save it in your virtual space.

For more information on virtualenvs, read this.

+174
Aug 02 2018-12-12T00:
source share

For python2.x :

 sudo pip install BeautifulSoup4 

For python3 :

 sudo apt-get install python3-bs4 
+47
Jul 04 '15 at 13:35
source share

Just a note on Balthazar's answer. Launch

 pip install BeautifulSoup4 

didn't work for me. Use instead

 pip install BeautifulSoup4 
+10
Mar 14 '15 at 18:27
source share

If you use Pycharm, go to settings - the project interpreter - install bs4. If you try to install BeautifulSoup, it will still show that there is not a single module named bs4.

+4
Sep 30 '16 at 18:44
source share

I will advise you to remove the bs4 library with this command:

pip uninstall bs4

and then install it with this command:

sudo apt-get install python3-bs4

I encountered the same problem on Linux Ubuntu when I used the following command to install the bs4 library:

pip install bs4

+3
Apr 17 '18 at 18:08
source share

If you use Anaconda to manage packages, follow these steps:

conda install -c anaconda beautifulsoup4

+1
Aug 10 '18 at 5:57
source share
 pip3 install BeautifulSoup4 

Try this. It works for me.

+1
Dec 29 '18 at 21:38
source share

The easiest way is to use easy_install.

 easy_install bs4 

It will work if pip fails.

0
Apr 19 '18 at 21:45
source share

Try this:

 sudo python3 -m pip install bs4 
0
Jun 10 '19 at 9:59
source share



All Articles