This question already has answers here:
ImportError: No Module Named bs4 (BeautifulSoup)
                                
                                    (12个答案)
                                
                        
                                5年前关闭。
            
                    
我在OSX中使用pip安装了BeautifulSoup4,但仍收到此错误:

dyn-72-33-214-45:craiglist mona$ python t1.py
Traceback (most recent call last):
  File "t1.py", line 1, in <module>
    from bs4 import BeautifulSoup
ImportError: No module named bs4


知道如何解决吗?

dyn-72-33-214-45:craiglist mona$ pip install BeautifulSoup4
....
Successfully installed BeautifulSoup4
Cleaning up...

最佳答案

我使用easy_install安装了它,现在可以使用了。但是首先您应该使用sudo su

dyn-72-33-214-45:craiglist mona$ sudo su
sh-3.2# easy_install beautifulsoup4

关于python - ImportError:没有名为bs4的模块,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/25697184/

10-12 19:02