1

我正在尝试在 python 中导入一个包含以下行的模块:

#setup.py
def isnumber(pause):
    try:
        float(pause)
        return True
    except ValueError:
        return False

我试图这样称呼它:

#program.py
import setup

但我收到以下错误:

    Traceback (most recent call last):
  File "C:\Users\rthompson@iingen.unam.mx\ralph\programas\python\scraper\release\program.py", line 4, in <module>
    import setup
  File "C:\Users\rthompson@iingen.unam.mx\ralph\programas\python\lib\setup.py", line 55, in <module>
    download_url="http://www.crummy.com/software/BeautifulSoup/download/"
  File "C:\Users\rthompson@iingen.unam.mx\ralph\programas\python\lib\distutils\core.py", line 140, in setup
    raise SystemExit, gen_usage(dist.script_name) + "\nerror: %s" % msg
SystemExit: usage: program.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
   or: program.py --help [cmd1 cmd2 ...]
   or: program.py --help-commands
   or: program.py cmd --help

error: no commands supplied

setup.py 中的第 55 行对应return True于上面的代码。

如果没有 isnumber 函数,导入将按预期工作。

谁能看到我做错了什么?

4

1 回答 1

2

您决定将您的模块称为“setup.py”。这是一个危险的名称,因为它通常用于 Python 模块的构建/安装脚本,就像您已经拥有的一样。选择一个不同的名称。

于 2012-04-14T23:49:31.293 回答