批处理:启动pipenv shell,然后在虚拟环境中运行命令 [英] batch: launch pipenv shell, then run command in the virtual environment

查看:506
本文介绍了批处理:启动pipenv shell,然后在虚拟环境中运行命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一个批处理脚本:

Z:
cd Z:\different_directory
pipenv shell
cd ..\another_directory


:End
cmd  /k

这里发生的是启动了pipenv Shell,但是虚拟环境没有CD.相反,一旦退出pipenv,它就会运行cd命令.

是否可以使用此批处理脚本从pipenv内部运行命令?

解决方案

您可以使用pipenv run代替pipenv shell直接运行python命令或批处理脚本.您将无法直接运行pipenv run cd ../another_dir,但是我假设这不是此操作的主要目标,因为您只能在该会话中更改目录.您可以使用

创建一个批处理脚本,例如test.bat.

cd ../another_dir
python test.py

然后使用pipenv run test.bat运行它.下面的页面有更多详细信息.

来源: http://witkowskibartosz.com/blog/pipenv_run_vs_pipenv_shell.html#.W2SBZflKhaQ

Here is a batch script:

Z:
cd Z:\different_directory
pipenv shell
cd ..\another_directory


:End
cmd  /k

What happens here is that the pipenv shell gets launched, but the virtual environment does not cd. Instead, once I exit the pipenv, it then runs the cd command.

Is it possible to run a command from inside the pipenv using this batch script?

解决方案

You can use pipenv run instead of pipenv shell to directly run a python command or a batch script. You won't be able to run pipenv run cd ../another_dir directly, but I'm assuming that isn't the main goal of this since you'd only be changing the directory in that session. You can create a batch script, say test.bat, with

cd ../another_dir
python test.py

Then run it with pipenv run test.bat. The page below has more details.

source: http://witkowskibartosz.com/blog/pipenv_run_vs_pipenv_shell.html#.W2SBZflKhaQ

这篇关于批处理:启动pipenv shell,然后在虚拟环境中运行命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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