How to install beautifulsoup into python3, when de

2020-05-30 04:23发布

问题:

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?

回答1:

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

pip3 install beautifulsoup4

See doc



回答2:

Run as root:

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

Afterwards import it like this:

import bs4


回答3:

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


回答4:

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

python -m pip install bs4