简体   繁体   中英

How to install a 3rd party module in Python?

I really need someone to dumb this down for me. I'm new to programming and Python, and I'd like to download and install BeautifulSoup. I thought I had downloaded, unzipped it, and and ran the setup, but when I try to import I get:

Traceback (most recent call last):
  File "C:\py3e_source\mc video\MC video count.py", line 6, in <module>
    from BeautifulSoup import BeautifulSoup
ImportError: No module named BeautifulSoup

When I run the setup, I get in the Python Shell:

Traceback (most recent call last):
  File "C:\Python31\Lib\beautifulsoup4-4.3.2\setup.py", line 27, in <module>
    "Topic :: Software Development :: Libraries :: Python Modules",
  File "C:\Python31\lib\distutils\core.py", line 137, in setup
    raise SystemExit(gen_usage(dist.script_name) + "\nerror: %s" % msg)
SystemExit: usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
   or: setup.py --help [cmd1 cmd2 ...]
   or: setup.py --help-commands
   or: setup.py cmd --help

error: no commands supplied

I'm wondering whether I put the module in the right location on my Windows PC, did I skip a step somewhere?

$ sudo apt-get install python-bs4

>>> from bs4 import BeautifulSoup
>>> 

You can try directly installing it using " sudo apt-get install package name " command.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM