从已安装的软件包中执行Python脚本
I have a Python package that contains a script:
pip show -f my-package
Results in
my-package-path/script.py
I would like to execute script.py, something like:
pip install my-package
python3 my-package-path.script.py
But it doesn't work.这样做的标准方式是什么?
I have a Python package that contains a script:
pip show -f my-package
Results in
my-package-path/script.py
I would like to execute script.py, something like:
pip install my-package
python3 my-package-path.script.py
But it doesn't work. What's the standard way of doing this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您访问并修改
my -package
setup.py(如果使用setuptools) - 您可以将Entry_points添加到setup()
呼叫,如果正确完成,则可以运行将脚本直接添加到路径中。示例:现在,当该软件包安装后,将有一个可执行的可执行文件
aistool
,该软件包运行main(Main()
方法从aistool.main.main.main
If you access and modify
my-package
setup.py (if setuptools is used) - you could add entry_points tosetup()
call and if thats done correctly, you can run the script directly as its added to the path. Example:Now, when that package gets installed, there will be an executable called
AISTool
which runsmain()
method fromAISTool.main