如何在Python中安装第三方模块?

时间:2014-02-20 03:43:00

标签: python module

我真的需要有人为我愚蠢。我是编程和Python的新手,我想下载并安装BeautifulSoup。我以为我已经下载,解压缩它,并运行设置,但当我尝试导入时,我得到:

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

当我运行安装程序时,我进入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

我想知道我是否将模块放在Windows PC上的正确位置,是否在某个地方跳过了一步?

1 个答案:

答案 0 :(得分:0)

$ sudo apt-get install python-bs4

>>> from bs4 import BeautifulSoup
>>> 

您可以尝试使用“sudo apt-get install package name”命令直接安装它。