Shebang线 - 多个允许的口译员按订单
我有一个需要Python3.7或以上的脚本。 我有多个具有不同Python版本的系统。所有这些都有Python3.7或Python3.8,但仅仅是“ Python3”也可以是Python3.6。
有没有办法使Shebang系列使用Python3.7或Python3.8?如果没有,则失败。
我尝试了十亿个选择,没有任何可行的方法。我希望有类似的东西:
#!/usr/bin/python3.7 || /usr/bin/python3.8
或者
#!/usr/bin/python3.7
#!/usr/bin/python3.8
让我很难过
是nada ..我也无法搜索它,这有点 默认情况下并在每种设置上安装Python3.7并不是一个选择(这会使生活很棒)。
I've got a script that requires python3.7 or above.
I've got multiple systems each with different python versions. all of them have either python3.7 or python3.8 but just "python3" can also be python3.6.
Is there a way to make a shebang line take either python3.7 or python3.8? and fail if none exist of course.
I tried a billion of options and nothing works. I was hoping for something like:
#!/usr/bin/python3.7 || /usr/bin/python3.8
or
#!/usr/bin/python3.7
#!/usr/bin/python3.8
but nada.. I also couldn't google it up which kinda makes me sad but who knows maybe the answer is there somewhere and I'm just using a bizarre jargon
these are not systems I can change defaults on and installing python3.7 on each such setup is sadly not an option (would make life awesome).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Shebang只需要指向实际的可执行文件即可。
可执行文件可以是找到python解释器的合适版本的;例如,请参见长期以来在Windows上流行的
py
工具,但现在也可以在真实的计算机上提供。其他平台。最终,某个地方需要在用户的
路径
上,显然您不会总是控制。如果您针对不老练的用户,则可能考虑以编译后的可执行文件,预包装的Docker映像或类似类似的内容提供代码。The shebang simply needs to point to an actual executable.
That executable can be one which finds a suitable version of the Python interpreter; see for example the
py
tool which was popular on Windows for a long time but which is now also being made available onreal computers.other platforms.Ultimately, something somewhere needs to be on the user's
PATH
, which obviously you will not always have control over. If you are targeting unsophisticated users, perhaps look into providing your code in a compiled executable, a prepackaged Docker image, or something vaguely like that.