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

前端 未结 5 1427
春和景丽
春和景丽 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:21

    Use pip3

    sudo pip3 install BeautifulSoup4
    

    If you cannot run pip3 install it with the following:

    sudo apt-get install python3-setuptools
    sudo easy_install3 pip 
    
    
    xxx@Ubuntu14:~/Desktop$ sudo pip3 install BeautifulSoup4
    [sudo] password for xxx:
    Downloading/unpacking BeautifulSoup4
      Downloading beautifulsoup4-4.3.2.tar.gz (143kB): 143kB downloaded
      Running setup.py (path:/tmp/pip_build_root/BeautifulSoup4/setup.py) egg_info for package BeautifulSoup4
    
    Installing collected packages: BeautifulSoup4
      Running setup.py install for BeautifulSoup4
        Skipping implicit fixer: buffer
        Skipping implicit fixer: idioms
        Skipping implicit fixer: set_literal
        Skipping implicit fixer: ws_comma
    
    Successfully installed BeautifulSoup4
    Cleaning up...
    xxx@Ubuntu14:~/Desktop$ python3
    Python 3.4.2 (default, Oct  8 2014, 13:08:17)
    [GCC 4.9.1] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>> from bs4 import BeautifulSoup
    >>> 
    

提交回复
热议问题