学习网络抓取时,第一步出现问题。
执行示例代码
- from urllib.request import urlopen
- from bs4 import BeautifulSoup
- html = urlopen("http://www.pythonscraping.com/exercises/exercise1.html")
- bsObj = BeautifulSoup(html, "html.parser")
- print(bsObj.h1)
执行结果
Traceback (most recent call last):
File "D:/install/Python_web Scraping/chapter1/BeautifulSoup.py", line 2, in <module> from bs4 import BeautifulSoup ModuleNotFoundError: No module named ‘bs4‘
备注:在终端中beautiful soup已经成功安装,但是在IDLE中依然出现该问题。
解决办法
1.在PyCharm Python文件选项中选择设置选项点进去
2.然后选择Project Interpreter
3.双击Pip
4.搜索出bs4,点击安装即可,会提示安装成功的消息
Python中安装bs4后,pycharm依然报错ModuleNotFoundError: No module named 'bs4'
原文地址:https://www.cnblogs.com/illusion1010/p/9657568.html
时间: 2024-10-12 10:51:20