ModuleNotFoundError:没有名为'bs4'的模块

rob*_*777 6 python beautifulsoup

我仍然是编码的新手!试图从在线教程中学习,但我似乎陷入了第一步!我想我安装了bs4,但它没有出现在python3中,是否安装在错误的地方?

robbie$ sudo -H pip install bs4
Requirement already satisfied: bs4 in /Library/Python/2.7/site-packages
Requirement already satisfied: beautifulsoup4 in /Library/Python/2.7/site-packages (from bs4)
Robbies-MBP:~ robbie$ python3
Python 3.6.1 (v3.6.1:69c0db5050, Mar 21 2017, 01:21:04) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import bs4
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'bs4'
Run Code Online (Sandbox Code Playgroud)

任何帮助将不胜感激 :)

Val*_*tin 11

要求已经满足:/ Library/Python/2.7/site-packages中的bs4

Python 3.6.1(v3.6.1:69c0db5050,2017年3月21日,01:21:04)

您已经为Python 2.7安装了该模块,但是您正在使用并尝试import使用Python 3.6.

你必须pip3像你使用一样使用python3.


pca*_*ana 5

如果您使用的是python 3,那么您应该使用 pip 3。为了在 ubuntu 中安装它:

sudo apt install python3-pip
Run Code Online (Sandbox Code Playgroud)

然后使用以下命令安装模块 bs4:

pip3 install bs4
Run Code Online (Sandbox Code Playgroud)