batch: launch pipenv shell, then run command in the virtual environment

我只是一个虾纸丫 提交于 2020-05-15 08:47:07

问题


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?


回答1:


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



来源:https://stackoverflow.com/questions/51290808/batch-launch-pipenv-shell-then-run-command-in-the-virtual-environment

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!