27

I have both Python 2.7 and Python 3.5 installed. When I type pip install beautifulsoup4 it tells me that it is already installed in python2.7/site-package directory.

But how do I install it into the python3 dir?

2

6 Answers 6

70

I think pip3 will satisfy your needs, use the below command on the terminal:

pip3 install beautifulsoup4

See doc

15

Run as root:

apt-get install python3-bs4
#or
pip3 install beautifulsoup4

Afterwards import it like this:

import bs4
2
  • Do you happen to know why it is installed as beautifulsoup4 and called as bs4? May 13, 2020 at 5:50
  • 1
    @Mischief_Monkey No, I don't know but probably so you don't have to write import beautifulsoup4 as bs4 it saves a lot of typing when you try to access classes from the module e.g. bs4.PageElement May 14, 2020 at 14:51
7

If you’re using a recent version of Debian or Ubuntu Linux, you can install Beautiful Soup with the system package manager:

$ apt-get install python-bs4 (for Python 2)
$ apt-get install python3-bs4 (for Python 3)

Afer install import the library

from bs4 import BeautifulSoup
3

The package is bs4 and can be installed with following command:

python -m pip install bs4
1

I had some mismatch between Python version and Beautifulsoup. I was installing this project Th3Jock3R/LinuxGSM-Arma3-Mod-Update to a linux centos8 dedicated Arma3 server. Python3 and Beautifulsoup4 seem to match.So I updated Python3, removed manually Beautifulsoup files and re-installed it with: sudo yum install python3-beautifulsoup4 (note the number 3). Works. Then pointing directories in Th3Jock3R:s script A3_SERVER_FOLDER = "" and A3_SERVER_DIR = "/home/arma3server{}".format(A3_SERVER_FOLDER) placing and running the script in same folder /home/arma3server with python3 update.py. In this folder is also located new folder called 'modlists' Now the lightness of mod loading blows my mind. -Bob-

1
  • Pinpointed the location of files.
    – Peacebob
    Jan 30, 2022 at 22:38
0

If you are on windows, this works for Python3 as well py -m pip install bs4

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.