Ubuntu - How to install a Python module (BeautifulSoup) on Python 3.3 instead of Python 2.7?

前端 未结 5 1438
春和景丽
春和景丽 2021-02-07 14:36

I have this code (as written in BS4 documentaion):

  from bs4 import BeautifulSoup

When I run the script (using python3) I get the error:

5条回答
  •  南笙
    南笙 (楼主)
    2021-02-07 15:16

    Ubuntu has beautifulsoup packaged. I found it by running apt-cache search

    $ apt-cache search beautifulsoup
    

    I see it has both a 2.7 and 3.3 version in the results. You can get the 3.3 version by installing python3-bs4

    $ sudo apt-get install python3-bs4
    

提交回复
热议问题