[英]Importing function from Python script hosted on Github
Is there a simply way to download/save a Python script hosted on Github and then import a function within that script?有没有一种简单的方法来下载/保存托管在 Github 上的 Python 脚本,然后在该脚本中导入一个函数? I could manually save it and then import the function I need (of course), but I'd like to find a more self-contained solution.
我可以手动保存它,然后导入我需要的函数(当然),但我想找到一个更独立的解决方案。 Ideally, I'd like to be able to send it to someone and have them run my script without having to manually download anything.
理想情况下,我希望能够将其发送给某人并让他们运行我的脚本,而无需手动下载任何内容。
Any help?有什么帮助吗?
You could use setuptools
and write custom setup
script for your package.您可以使用
setuptools
并为您的包编写自定义setup
脚本。 Wrap your script into python package.将您的脚本包装到 python 包中。
So users will be able install it via pip
with just a single line:因此,用户只需一行即可通过
pip
安装它:
pip install git+https://github.com/yournickname/reponame.git
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.