即使安装了BeautifulSoap的ImportError也是如此

时间:2018-04-26 18:11:02

标签: python pip importerror

我一直试图用

导入BeautifulSoap(美丽的肥皂4,而不是3)

private void setDepth(GL10 gl){ float max = -5.25f; float min = -6.25f; float A = (max - min) / 2; float z; double temp = A * -Math.abs(Math.sin(2 * (round(angleRectangle) * pi / 180))) + max; String s = String.format("%.2f", temp).trim(); z = Float.parseFloat(s); depth = z; }

但我一直得到一个ImportError:

from bs4 import BeautifulSoap

我已经通过Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: cannot import name 'BeautifulSoap' pip install bs4已经安装了带有点子的BeautifulSoap4。出于某种原因,pip install --upgrade --force-reinstall beautifulsoup4给了我:

pip install beautifulsoap4

无论如何,只使用Could not find a version that satisfies the requirement beautifulsoap4 (from versions: ) No matching distribution found for beautifulsoap4 导入bs4就没有错误。我的所有Python文件都没有命名为bs4.py或beautifulsoap.py或其他任何类型。有谁知道为什么会这样?我一直在寻找过去一小时的原因:(

提前致谢!

2 个答案:

答案 0 :(得分:1)

pip install bs4pip install beautifulsoap4都没有安装BeautifulSoup(Soup!= Soap)

命令是 pip install beautifulsoup4

from bs4 import BeautifulSoup

检查Docs

如果按pip搜索名称,则可以看到:     pip search bs4:

  

bs4(0.0.1) - 美丽汤的假包装

pip search beautifulsoup4
  

beautifulsoup4(4.6.0) - 屏幕抓取库

答案 1 :(得分:1)

你有BeautifulSoup

的拼写错误

正确是from bs4 import BeautifulSoup