问题描述
这是一个批处理脚本:
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
,但是我假设这不是此操作的主要目标,因为您只能在该会话中更改目录.您可以使用
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,然后在虚拟环境中运行命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!