确保其他人可以运行我的python程序的可靠方法 [英] Robust way to ensure other people can run my python program

查看:109
本文介绍了确保其他人可以运行我的python程序的可靠方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望将python程序放置在GitHub上,并让其他人下载并在具有各种操作系统的计算机上运行该程序.我对python还是比较陌生,但是已经使用了足够多的Python,以至于注意到让所有包含的模块的各个版本一起工作可能会出现问题.我刚刚发现使用requirements.txt(由pipreqs生成并通过命令pip install -r /path/to/requirements.txt进行了部署),但是很惊讶地注意到requirements.txt并未真正说明正在使用的是哪个版本的python,因此显然不是完整的解决方案.所以我的问题是:需要什么规格/文件/其他东西才能确保下载我的项目的人实际上能够以最少的问题运行它.

I wish to place a python program on GitHub and have other people download and run it on their computers with assorted operating systems. I am relatively new to python but have used it enough to have noticed that getting the assorted versions of all the included modules to work together can be problematic. I just discovered the use of requirements.txt (generated with pipreqs and deployed with the command pip install -r /path/to/requirements.txt) but was very surprised to notice that requirements.txt does not actually state what version of python is being used so obviously it is not the complete solution on its own. So my question is: what set of specifications/files/something-else is needed to ensure that someone downloading my project will actually be able to run it with the fewest possible problems.

编辑:我的计划将以投票最多的人为指导.但是到目前为止,在获得4个答案和127次查看后,没有一个答案甚至没有投票.如果某些答案不好,那么查看一些关于为什么不好的评论会很有用.

My plan was to be guided by whichever answer got the most upvotes. But so far, after 4 answers and 127 views, not a single answer has even one upvote. If some of the answers are no good, it would be useful to see some comments as to why they are no good.

推荐答案

您是否考虑过设置setup.py文件?这是将您所有...很好的设置捆绑到一个位置的便捷方法.因此,您的用户所需要做的就是A)复制您的存储库,B)运行pip install .来运行setup.py

Have you considered setting up a setup.py file? It's a handy way of bundling all of your... well setup into a single location. So all your user has to do is A) clone your repo and B) run pip install . to run the setup.py

对此有很多堆栈讨论.

以及请求者编写的句柄示例.

这应该涵盖大多数用例.现在,如果要使其真正可分发,则需要研究在PyPi中进行设置 ,官方的发行中心.

This should cover most use cases. Now if you want to make it truly distributable then you'll want to look into setting it up in PyPi, the official distribution hub.

此外,如果您要问如何使程序独立于操作系统",那么没有一个适合所有人的.这取决于您对代码的处理方式.需要研究您的特定代码如何与这些OS等交互.

Beyond that if you're asking how to make a program "OS independent" there isn't a one size fits all. It depends on what you are doing with your code. Requires researching how your particular code interacts with those OS's etc.

这篇关于确保其他人可以运行我的python程序的可靠方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆