如果沒有安裝包管理工具就執(zhí)行
1.首先執(zhí)行命令:sudo easy_install pip
安裝完成后執(zhí)行命令:pip install beautifulsoup4
然后運(yùn)行均唉,然后問題來了,居然提示沒有權(quán)限薛匪?报嵌?邦泄?
Collecting beautifulsoup4
Using cached beautifulsoup4-4.4.0-py2-none-any.whl
Installing collected packages: beautifulsoup4
Exception:
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/pip-7.1.0-py2.7.egg/pip/basecommand.py", line 223, in main
status = self.run(options, args)
File "/Library/Python/2.7/site-packages/pip-7.1.0-py2.7.egg/pip/commands/install.py", line 299, in run
root=options.root_path,
File "/Library/Python/2.7/site-packages/pip-7.1.0-py2.7.egg/pip/req/req_set.py", line 646, in install
**kwargs
File "/Library/Python/2.7/site-packages/pip-7.1.0-py2.7.egg/pip/req/req_install.py", line 813, in install
self.move_wheel_files(self.source_dir, root=root)
File "/Library/Python/2.7/site-packages/pip-7.1.0-py2.7.egg/pip/req/req_install.py", line 1008, in move_wheel_files
isolated=self.isolated,
File "/Library/Python/2.7/site-packages/pip-7.1.0-py2.7.egg/pip/wheel.py", line 339, in move_wheel_files
clobber(source, lib_dir, True)
File "/Library/Python/2.7/site-packages/pip-7.1.0-py2.7.egg/pip/wheel.py", line 310, in clobber
ensure_dir(destdir)
File "/Library/Python/2.7/site-packages/pip-7.1.0-py2.7.egg/pip/utils/__init__.py", line 70, in ensure_dir
os.makedirs(path)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/os.py", line 157, in makedirs
mkdir(name, mode)
OSError: [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/beautifulsoup4-4.4.0.dist-info'
這時(shí)候輸入命令:sudo easy_install beautifulsoup4
進(jìn)入Python輸入:from bs4 import BeautifulSoup
會發(fā)現(xiàn)提示:沒有這個(gè)模塊名撬腾,那是因?yàn)镸ac系統(tǒng)自帶了Python2.7 你要把beautifulsoup4寫到Python3的目錄文件里去
命令行輸入:pip3 install beautifulsoup4