【发布时间】:2023-03-06 21:14:01
【问题描述】:
我想按照本教程制作一个 CLI 应用程序: https://trstringer.com/easy-and-nice-python-cli/, 我的文件系统具有以下结构:
app/
├── README.md
├── install.sh
├── app
├── __init__.py
├── __main__.py
├── text.txt
├── text1.txt
└── text2.json
#the app.egg info was created automatically
├── app.egg-info
├── entry_points
├── SOURCES
└── setup.py
当我从终端调用应用程序时,我收到此错误:
FileNotFoundError: [Errno 2] No such file or directory: 'text1.txt',即使它清楚地在目录中。
在我尝试将脚本转换为 CLI 应用程序之前,我称该文本文件工作的代码,不确定我是否必须将这些文本文件移动到特定目录或指定我在某处需要这些文件。
这里setup.py:
from setuptools import setup
setup(
name = 'app',
version = '0.1.0',
packages = ['app'],
entry_points = {
'console_scripts': [
'app = app.__main__:some_function'
]
})
如果您需要有关代码的更多信息,或者想了解如何将我的 python 脚本转换为功能强大的 CLI 应用程序,请随时告诉我! 我也在使用 click。
【问题讨论】:
标签: python command-line-interface setuptools