Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 233
ERJAN Avatar asked Dec 29 '15 08:12

ERJAN


People also ask

How do I install Beautifulsoup for Python 3?

To install Beautifulsoup on Windows, Linux, or any operating system, one would need pip package. To check how to install pip on your operating system, check out – PIP Installation – Windows || Linux. Wait and relax, Beautifulsoup would be installed shortly.

How do you get Beautifulsoup in Python?

To use beautiful soup, you need to install it: $ pip install beautifulsoup4 . Beautiful Soup also relies on a parser, the default is lxml . You may already have it, but you should check (open IDLE and attempt to import lxml). If not, do: $ pip install lxml or $ apt-get install python-lxml .

Does pip use python3 or python2?

On Suse Linux 13.2, pip calls python3, but pip2 is available to use the older python version.

Can pip install python3?

pip installs the Python 2 version of the package, and pip3 will install the Python 3 version of the package. it should install all the modules listed on the file.


2 Answers

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

pip3 install beautifulsoup4 

See doc

like image 88
Alan Francis Avatar answered Sep 21 '22 01:09

Alan Francis


Run as root:

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

Afterwards import it like this:

import bs4 
like image 45
Mehdi Nellen Avatar answered Sep 23 '22 01:09

Mehdi Nellen