我在
cli
中有一个方法 mymodule
,它是我的程序的入口点。 cli
需要几个关键字参数。模块mymodule
确实不包含类似的内容
if __name__ == "__main__":
cli(...)
我如何为此指定运行配置?
我试过了
{
"name": "myentrypoint",
"type": "debugpy",
"request": "launch",
"module": "mymodule.cli",
"console": "integratedTerminal",
"args": [
"--arg1", "value1",
"--arg2", "value2"
],
"justMyCode": true
}
(如如何为 Python 模块制作 VScode launch.json 中的建议)
这给了我
/home/xxxxxx/projects/myproject/.venv/bin/python: Error while finding module specification for 'mymodule.cli' (ModuleNotFoundError: __path__ attribute not found on 'mymodule' while trying to find 'mymodule.cli')
通常我使用这个入口点使用诗歌
[tool.poetry.scripts]
myentrypoint= 'mymodule:cli'
然后从终端
poetry run myentrypoint --arg1 "value1" --arg2 "value2
cli
中设置
args
。看起来像:
{
"name": "myentrypoint",
"type": "debugpy",
"request": "launch",
"module": "mymodule",
"console": "integratedTerminal",
"args": [
"cli",
"--arg1", "value1",
"--arg2", "value2"
],
"justMyCode": true
}