Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
687 views
in Technique[技术] by (71.8m points)

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

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...