gpt4 book ai didi

Python 模块导入因未知原因失败

转载 作者:行者123 更新时间:2023-12-01 06:01:33 24 4
gpt4 key购买 nike

我正在尝试在 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 函数,导入将按预期进行。

有人能看出我做错了什么吗?

最佳答案

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

关于Python 模块导入因未知原因失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10158302/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com