Closed. This question is off-topic。它当前不接受答案。
                            
                        
                    
                
                            
                                
                
                        
                            
                        
                    
                        
                            想改善这个问题吗? Update the question,所以它是on-topic,用于堆栈溢出。
                        
                        去年关闭。
                                                                                            
                
        
我一直在尝试导入BeautifulSoap(Beautiful Soap 4,not 3)与

from bs4 import BeautifulSoap

但我不断收到一个ImportError:

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: cannot import name 'BeautifulSoap'


我已经通过pip install bs4pip install --upgrade --force-reinstall beautifulsoup4用pip安装了BeautifulSoap4。由于某些原因,pip install beautifulsoap4给我:

Could not find a version that satisfies the requirement beautifulsoap4 (from versions: )
No matching distribution found for beautifulsoap4


无论如何,仅使用import bs4导入bs4不会给我任何错误。我的Python文件都没有命名为bs4.py或beautifulsoap.py或任何类似名称。有谁知道为什么会这样吗?我一直在寻找过去一个小时的原因:(

提前致谢!

最佳答案

pip install bs4pip install beautifulsoap4均未安装BeautifulSoup(Soup!= Soap)

该命令是
pip install beautifulsoup4

from bs4 import BeautifulSoup


检查Docs

如果通过点子搜索名称,则可以看到:
    点搜索bs4:


  bs4(0.0.1)-虚拟包的美丽汤


pip search beautifulsoup4



  beautifulsoup4(4.6.0)-屏幕抓取库

关于python - 即使安装了BeautifulSoap,也会发生ImportError ,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/50049523/

10-10 05:37