question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Activate a pipenv environment without creating a new shell?

See original GitHub issue

Is it possible to activate a pipenv environment without creating a new shell?

Example:

user@host:~/some_project$ pipenv activate
(some_project-OH5ik22OJ) user@host:~/some_project$

(Edit:) I should mention that this is possible by running

user@host:~/some_project$ . `pipenv --venv`/bin/activate

But I’m more interested in the “why spawn a new shell?”

Why am I asking?

I guess I don’t really see the advantage of spawning a new shell. I do, however, see disadvantages:

  • When exiting the shell, your CWD changes to the path you were at when you spawned the shell, not the path you were in when exiting the shell
  • After exiting, you don’t get your command history from when you were inside the shell

Examples of the disadvantages:

user@host:~/some_project$echo "outside of shell"
outside of shell
user@host:~/some_project$pipenv shell
<snip>
(some_project-AGMeXx6P) user@host:~/some_project$cd src
(some_project-AGMeXx6P) user@host:~/some_project/src$ echo "inside shell"
inside shell
(some_project-AGMeXx6P) user@host:~/some_project/src$ exit
user@host:~/some_project$ history | tail -n 10                # dir changed!
   1  echo "outside of shell"
   2  pipenv shell
   3  history | tail -n 10                                    # `echo "inside shell"` missing!

Describe you environment
  1. Windows, WSL, and Linux
  2. Python version: 3.5.2
  3. Pipenv version: 8.2.6

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:15
  • Comments:16 (5 by maintainers)

github_iconTop GitHub Comments

23reactions
techalchemycommented, Oct 21, 2017

You can use pipenv —venv to get the location of the virtualenv and activate it like a normal virtualenv.

21reactions
radzhomecommented, Oct 17, 2018

I used . $(pipenv --venv)/bin/activate to avoid execute “Permission denied” error

Read more comments on GitHub >

github_iconTop Results From Across the Web

Pipenv shell command creates new venv instead of loading ...
just go to that project/venv bin folder and then do source activate it will as activate as it is just a wrapper around...
Read more >
Basic Usage of Pipenv - Read the Docs
Next, activate the Pipenv shell: $ pipenv shell $ python --version. This will spawn a new shell subprocess, which can be deactivated by...
Read more >
How to manage Python projects with Pipenv - InfoWorld
To activate the environment, just navigate to your project directory and use pipenv shell to launch a new shell session or use pipenv...
Read more >
Pipenv & Virtual Environments
Using $ pipenv run ensures that your installed packages are available to your script. It's also possible to spawn a new shell that...
Read more >
Pipenv run vs Pipenv shell - Anselmos Blog
Pipenv has a run and shell, but which one should I use ? ... Pipenv - Activate a pipenv environment without creating a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found