如何解决ModuleNotFoundError:没有名为“ BeautifulSoup”的模块?

时间:2018-06-21 09:36:42

标签: python beautifulsoup

我正在学习Python,并且已经通过自制软件安装了python3。 然后我成功安装了BeautifulSoup和通过Pip3的请求。

the codes in terminal

Lorentzs-MacBook-Pro:~ Lorentz$ pip3 install beautifulsoup4
Collecting beautifulsoup4
  Using cached     https://files.pythonhosted.org/packages/9e/d4/10f46e5cfac773e22707237bfcd51bbffeaf0a576b0a847ec7ab15bd7ace/beautifulsoup4-4.6.0-py3-none-any.whl
Installing collected packages: beautifulsoup4
Successfully installed beautifulsoup4-4.6.0
Lorentzs-MacBook-Pro:~ Lorentz$ pip3 install requests
Requirement already satisfied: requests in     /usr/local/lib/python3.6/site-packages (2.19.1)
Requirement already satisfied: idna<2.8,>=2.5 in /usr/local/lib/python3.6/site-packages (from requests) (2.7)
Requirement already satisfied: urllib3<1.24,>=1.21.1 in /usr/local/lib/python3.6/site-packages (from requests) (1.23)
Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.6/site-packages (from requests) (2018.4.16)
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in /usr/local/lib/python3.6/site-packages (from requests) (3.0.4)
Lorentzs-MacBook-Pro:~ Lorentz$ python3 /Users/Lorentz/Desktop/py4e/Practice/test.py
Traceback (most recent call last):
  File "/Users/Lorentz/Desktop/py4e/Practice/test.py", line 3, in <module>
    import BeautifulSoup
ModuleNotFoundError: No module named 'BeautifulSoup'

当我运行我的python文件时,它会显示

import BeautifulSoup
ModuleNotFoundError: No module named 'BeautifulSoup'

我该如何解决?我已经尝试卸载python3,并通过自制软件重新安装它,然后再次重新安装Pip3,Requests和beautifulSoup,但它仍然向我显示错误。请协助解决此问题。

1 个答案:

答案 0 :(得分:0)

您尝试过吗?

from bs4 import BeautifulSoup