如何在Python Shell脚本中使用Pipenv? [英] How to use pipenv in Python shell script?

查看:282
本文介绍了如何在Python Shell脚本中使用Pipenv?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一个用Python编写的Shell脚本模块,因此我使用pipenv进行安装.我可以使用以下命令很好地运行命令:

I needed a module for a shell script I've written in Python, so I used pipenv to install it. I can run the command fine using:

~$ pipenv run python3 foo

现在,如果我只想在命令行上运行~$ foo(在MacOS上为鱼壳,已安装自制软件),如何在我的Python脚本的shebang中调用pipenv环境?还是有更好的方法?

Now, if I want to just run ~$ foo on the command line (fish shell on MacOS, homebrew installed), how do I invoke the pipenv environment in the shebang of my Python script? Or is there a better way?

推荐答案

使用 pipenv-shebang 您可以使用以下命令运行脚本

With pipenv-shebang you can run your script with

pipenv-shebang PATH/SCRIPT

或者您可以插入shebang

or you could insert the shebang

#!/usr/bin/env pipenv-shebang

仅需PATH/SCRIPT即可运行它.

这篇关于如何在Python Shell脚本中使用Pipenv?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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