Pipenv has a run and shell, but which one should I use ? That's the same question I've asked myself yesterday. Check out my brief summary about this!
Pipenv shell is used mainly as a
run it now, and leave.
It will create an active environemnt almost the same way as with
source env/bin/activate, but it will also do it within a new shell. That way you cannot use previous commands from history.
As it's using a sub-shell, it may not be advised to use it within your deployment/management.
For example if you want to make a
Dockerfile with Pipenv, you should not use
pipenv shell because it will not be activated for the next
RUN command or any other command that you may put with
You could use some type of sub-processing but that's far beyond easy and clean - so as using
pipenv --venv that gives you opportunity to reuse underlying virtualenv (by giving you place where is the v-env that you can activate manually).
Pipenv run is the main purpose for running next python commands. It will automatically activate environment for that command and execute anything you will put to it.
For example to run some specific python file that uses dependency you will:
pipenv run python main.py
That will activate env and run
python main.py in the env.
As posted by Dan Ryan(techalchemy) in this issue comment - you can should use
pipenv run for 'heavy lifting' and
pipenv shell for day-to-day convenience of dev tasks.
- Pipenv - Activate a pipenv environment without creating a new shell? #944
- Pipenv - pipenv shell loses history #297
- Pipenv - up/down arrow history doesn't work on pipenv shell on windows #876
- Virtualenv - site.py not compatible with python 2.7 #355
- Pew - Tab completion under pew? #150
- Pew - Arrow keys don't work in pew shell on Windows #166
- Pew - up/down arrow history doesn't work on pipenv shell on windows #165
That's it :) Comment, share or don't :)
If you have any suggestions what I should blog about in the next articles - please give me a hint :)
See you in the next episode! Cheers!