Python 导入时出现美化组错误

Python 导入时出现美化组错误,python,beautifulsoup,Python,Beautifulsoup,当我尝试导入beautifulsoup时,出现以下错误: Traceback (most recent call last): File "my_first_simple_script.py", line 2, in <module> from bs4 import BeautifulSoup ModuleNotFoundError: No module named 'bs4' 回溯(最近一次呼叫最后一次): 文件“my_first_simple_script.py”,

当我尝试导入beautifulsoup时,出现以下错误:

Traceback (most recent call last):
  File "my_first_simple_script.py", line 2, in <module>
    from bs4 import BeautifulSoup
ModuleNotFoundError: No module named 'bs4'
回溯(最近一次呼叫最后一次):
文件“my_first_simple_script.py”,第2行,在
从bs4导入BeautifulSoup
ModuleNotFoundError:没有名为“bs4”的模块
我尝试通过以下方式导入它: 从bs4导入BeautifulSoup

我的python版本是3.6.1,而beautifulsoup是:'beautifulsoup4==4.6.0'


我做错了什么?

我使用了命令:pip install BeautifulSoup4。我发现对于python3或更高版本,应该使用pip3而不是pip,所以我这样做了,但没有起作用。当我第一次用pip卸载BeautifulSoup4卸载beautifulsoup,然后用pip3安装BeautifulSoup4命令再次安装它时,它开始工作。

您是如何安装beautifulsoup的?您确定它与python 3.6.1安装在同一个virtualenv中吗?运行命令
which pip
(或pip3)、
which python
(或which python3)和
pip freeze
(或pip3 freeze),并将结果发布在这里。我使用了命令:pip install BeautifulSoup4。我发现对于python3或更高版本,应该使用pip3而不是pip,所以我这样做了,但没有起作用。当我第一次用pip卸载BeautifulSoup4卸载beautifulsoup,然后用pip3安装BeautifulSoup4命令再次安装它时,它就开始工作了。