Pipenv: Provide way to run commands without needing to always prepend “pipenv run”

Created on 23 Jan 2017  ·  6Comments  ·  Source: pypa/pipenv

I realise right now your tool does not needs to activate any env (I actually like it, it makes it easier for beginers to get in) but I will use pipenv activate eventually.

I would like to suggest to get some inspiration from pew for the virtualenv part. It has some nice benefits:

  • it's pure Python and works with any shell, even in windows. No need for activation script.
  • it spawns a subshell. Meaning you don't activate a virtualenv, you get into a brand new process. To exit the env, you just exist the shell (Ctrl + D). No side effect, back to your previous session.

Most helpful comment

For people stumbling here in the future, please avoid activate scripts unless you have a very good reason. What OP asked is already implemented as pipenv shell, and you should use it. Activate scripts are already considered not best practice, and every point OP pointed out is benefit of pipenv shell, not activate scripts.

Again, unless you have a perfectly good reason, please use pipenv shell (or pipenv run). Activate scripts are not implemented in Pipenv for a reason.

I am going to change the title so it reflects the actual purpose, and make this issue less searchable.

All 6 comments

I will definitely look into it. Right now, you can run $ pipenv shell and you will get a shell.

You are on HN FP right now. Although you were with Maya as well, I sense this project will actually gather much more attention because, like request, it's providing something with not great current solution. It's already booming.

✨🍰✨

$ source $(pipenv --venv)/bin/activate

😅

This will work on Powershell (since pipenv shell behaves strangely on Windows):

Invoke-Expression -Command ($(pipenv --venv) + "\\Scripts\\activate.ps1")

For people stumbling here in the future, please avoid activate scripts unless you have a very good reason. What OP asked is already implemented as pipenv shell, and you should use it. Activate scripts are already considered not best practice, and every point OP pointed out is benefit of pipenv shell, not activate scripts.

Again, unless you have a perfectly good reason, please use pipenv shell (or pipenv run). Activate scripts are not implemented in Pipenv for a reason.

I am going to change the title so it reflects the actual purpose, and make this issue less searchable.

Was this page helpful?
0 / 5 - 0 ratings