How can I install the Beautiful Soup module on the Mac?
我在没有找到解决方案的情况下阅读了这个:http://docs.python.org/install/index.html
"正常"方式是:
- 去美丽汤网站,http://www.crummy.com/software/beautiful soup/
- 下载软件包
- 打开它
- 在终端窗口中,
cd 指向生成的目录 python setup.py install 型
另一种解决方案是使用
1 2 3 | easy_install BeautifulSoup4 # for older v3: # easy_install BeautifulSoup |
我认为目前正确的做法是由
1 | pip install beautifulsoup4 |
由于Python中的最后一个更改,请参见此处的讨论。过去不是这样的。
布莱恩也打败了我,但既然我已经有了成绩单:
简易安装
1 2 3 4 5 6 7 8 9 | 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 |
…或者普通的无聊方式:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | 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 ...> |
下载包并将其解包。在终端中,转到包的目录并键入
1 | python setup.py install |
根据http://for-ref-only.blogspot.de/2012/08/installing-beautifulsoup-for-python-3.html的建议,我使用windows命令提示符:
1 | C:\Python\Scripts\easy_install c:\Python\BeautifulSoup\beautifulsoup4-4.3.1 |
其中beautifulsoupeautifulsoup4-4.3.1是下载并提取的beautifulsoup4-4.3.1.tar文件。它起作用了。
1 | sudo yum remove python-beautifulsoup |
或
1 | sudo easy_install -m BeautifulSoup |
可以删除旧版本3