'How to install beautifulsoup into python3, when default dir is python2.7?

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?



Solution 1:[1]

Run as root:

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

Afterwards import it like this:

import bs4

Solution 2:[2]

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

Solution 3:[3]

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

python -m pip install bs4

Solution 4:[4]

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-

Solution 5:[5]

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

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Mehdi Nellen
Solution 2 Hossain Misho
Solution 3 Shvet Chakra
Solution 4
Solution 5 jubot