当默认目录为python2.7时,如何将beautifulsoup安装到python3中?
我已经安装了Python2.7和Python3.5。当我键入当默认目录为python2.7时,如何将beautifulsoup安装到python3中?,python,python-3.x,beautifulsoup,pip,Python,Python 3.x,Beautifulsoup,Pip,我已经安装了Python2.7和Python3.5。当我键入pip install beautifulsoup4时,它告诉我它已经安装在python2.7/site-package目录中 但是如何将其安装到python3目录中?我认为pip3将满足您的需要,请在终端上使用以下命令: pip3 install beautifulsoup4 请参见以root用户身份运行: apt-get install python3-bs4 #or pip3 install beautifulsoup4 然后
pip install beautifulsoup4
时,它告诉我它已经安装在python2.7/site-package目录中
但是如何将其安装到python3目录中?我认为pip3将满足您的需要,请在终端上使用以下命令:
pip3 install beautifulsoup4
请参见以root用户身份运行:
apt-get install python3-bs4
#or
pip3 install beautifulsoup4
然后像这样导入它:
import bs4
该软件包是bs4,可以使用以下命令安装:
python -m pip install bs4
如果您使用的是最新版本的Debian或Ubuntu Linux,则可以使用system package manager安装Beauty Soup:
$ apt-get install python-bs4 (for Python 2)
$ apt-get install python3-bs4 (for Python 3)
安装后导入库
from bs4 import BeautifulSoup
如果您在windows上,这也适用于Python3
py-m pip通过运行pip3
来安装bs4?您是否知道为什么它被安装为beautifulsoup4并称为bs4?没有,我不知道,但可能您不必编写import beautifulsoup4作为bs4
当您尝试从模块访问类时,例如bs4.PageElement