使用pip安装BeautifulSoup4模块

时间:2023-03-08 16:45:38
使用pip安装BeautifulSoup4模块

1.测试是否安装了BeautifulSoup4模块

import bs4
print bs4

执行报错说明没有安装该模块

Traceback (most recent call last):
File "D:\work_java\python\src\baike_spider\test.py", line , in <module>
import bs4
ImportError: No module named bs4

2.使用pip安装BeautifulSoup4模块

 C:\Python27\Scripts 的目录

//  :    <DIR>          .
// : <DIR> ..
// : , easy_install-2.7.exe
// : , easy_install.exe
// : , pip.exe
// : , pip2..exe
// : , pip2.exe
个文件 , 字节
个目录 ,,, 可用字节 C:\Python27\Scripts>pip install beautifulsoup4
You are using pip version 7.0., however version 8.0. is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Collecting beautifulsoup4
Downloading beautifulsoup4-4.4.-py2-none-any.whl (81kB)
% |████████████████████████████████| 81kB 111kB/s
Installing collected packages: beautifulsoup4
Successfully installed beautifulsoup4-4.4.

2.再重新测试正常

<module 'bs4' from 'C:\Python27\lib\site-packages\bs4\__init__.pyc'>