Activate a pipenv environment without creating a new shell?
See original GitHub issueIs 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
- Windows, WSL, and Linux
- Python version: 3.5.2
- Pipenv version: 8.2.6
Issue Analytics
- State:
- Created 6 years ago
- Reactions:15
- Comments:16 (5 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
You can use
pipenv —venv
to get the location of the virtualenv and activate it like a normal virtualenv.I used
. $(pipenv --venv)/bin/activate
to avoid execute “Permission denied” error