问题
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