Bri*_*per 77

"正常"的方式是:

另一种解决方案是使用easy_install.转到http://peak.telecommunity.com/DevCenter/EasyInstall),使用该页面上的说明安装软件包,然后在终端窗口中键入:

easy_install BeautifulSoup4
# for older v3:
# easy_install BeautifulSoup
Run Code Online (Sandbox Code Playgroud)

easy_install将负责下载,拆包,构建和安装包.使用的优点easy_install是它知道如何搜索许多不同的Python包,因为它查询PyPI注册表.因此,一旦您使用easy_install了计算机,就可以通过shell中的一个命令安装许多不同的第三方软件包.

  • 安装完成后,对BeautifulSoup4.0使用此导入命令:"from bs4 import BeautifulSoup" (10认同)

Léo*_* 준영 26

我认为目前正确的做法是pip像Pramod评论一样

pip install beautifulsoup4
Run Code Online (Sandbox Code Playgroud)

因为Python的最后更改,请参阅此处的讨论.过去并非如此.


Aar*_*paa 14

Brian也打败了我,但因为我已经有了成绩单:

easy_install的

aaron@ares ~$ sudo easy_install BeautifulSoup
Searching for BeautifulSoup
Best match: BeautifulSoup 3.0.7a
Processing BeautifulSoup-3.0.7a-py2.5.egg
BeautifulSoup 3.0.7a is already the active version in easy-install.pth

Using /Library/Python/2.5/site-packages/BeautifulSoup-3.0.7a-py2.5.egg
Processing dependencies for BeautifulSoup
Finished processing dependencies for BeautifulSoup
Run Code Online (Sandbox Code Playgroud)

..或正常的无聊方式:

aaron@ares ~/Downloads$ curl http://www.crummy.com/software/BeautifulSoup/download/BeautifulSoup.tar.gz > bs.tar.gz
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 71460  100 71460    0     0  84034      0 --:--:-- --:--:-- --:--:--  111k

aaron@ares ~/Downloads$ tar -xzvf bs.tar.gz 
BeautifulSoup-3.1.0.1/
BeautifulSoup-3.1.0.1/BeautifulSoup.py
BeautifulSoup-3.1.0.1/BeautifulSoup.py.3.diff
BeautifulSoup-3.1.0.1/BeautifulSoupTests.py
BeautifulSoup-3.1.0.1/BeautifulSoupTests.py.3.diff
BeautifulSoup-3.1.0.1/CHANGELOG
BeautifulSoup-3.1.0.1/README
BeautifulSoup-3.1.0.1/setup.py
BeautifulSoup-3.1.0.1/testall.sh
BeautifulSoup-3.1.0.1/to3.sh
BeautifulSoup-3.1.0.1/PKG-INFO
BeautifulSoup-3.1.0.1/BeautifulSoup.pyc
BeautifulSoup-3.1.0.1/BeautifulSoupTests.pyc

aaron@ares ~/Downloads$ cd BeautifulSoup-3.1.0.1/

aaron@ares ~/Downloads/BeautifulSoup-3.1.0.1$ sudo python setup.py install
running install
<... snip ...>
Run Code Online (Sandbox Code Playgroud)