For bash shell, when I try activating virtualenv by pip shell
, it doesn't prepend virtualenv name before bash prompt.
$ # Global pip
$ pip freeze | wc -l
61
$ pipenv shell
Spawning environment shell (/bin/bash).
$ pip freeze
$ # Means we are inside virtualenv as there is no package
$ which python
/XXXXXX/.venv/bin/python
$ source .venv/bin/activate
(playpipenv) $
It might be my bashrc. Will wait till anyone confirms it. Thanks
Typo pipenv shell
. Works for me. What's your system etc?
OS X 10.11.6, and Zsh 5.0.8, pipenv shell
works as expected, with the venv name prepended. Just for reference.
I need to play around with bash, but it seems to be working fine on my machine.
Can someone play around with it? The lines in question are here:
https://github.com/kennethreitz/pipenv/blob/master/pipenv/cli.py#L445-L447
If source is sent in, two prompts are present in bash.
$ pipenv shell
Creating a Pipfile for this project...
Creating a virtualenv for this project...
Using real prefix '/Users/jpadilla/.pyenv/versions/2.7.9'
New python executable in /Users/jpadilla/Desktop/pipenv/.venv/bin/python2.7
Also creating executable in /Users/jpadilla/Desktop/pipenv/.venv/bin/python
Installing setuptools, pip, wheel...done.
Virtualenv location: /Users/jpadilla/Desktop/pipenv/.venv
Spawning environment shell (/bin/bash).
(pipenv)
So a few comments. If I convert the suspicious if
if 'bash' not in shell:
c.send(activate_virtualenv() + '\n')
to just
c.send(activate_virtualenv() + '\n')
my prompt works properly both in zsh and bash.
I have to ask though why are we sourcing the activation file both before and after execing the shell and not just after?
Similar to @spiliopoulos, I just found that commenting out the conditional line fixes it.
However, it does mangle the output (Ubuntu 16.04.01, Bash 4.3.46):
$ pipenv shell
Spawning environment shell (/bin/bash).
$ source /home/****/.venv/bin/activate
(pipenv) $
Just at work right now but I can investigate further later if nobody beats me to it ;)
Excellent, I'll remove it.
@jessebraham
What kind of mangling did you observe?
@jessebraham Have you pulled the latest changes. There was a seperate issue with the size of the terminal not updating.
@spiliopoulos Sorry I should have been more clear.
Installed via pip, prior to my local changes, the output after running pipenv shell
was as follows:
$ pipenv shell
Spawning environment shell (/bin/bash).
$
Following my changes, the output of pipenv shell
was as follows:
$ pipenv shell
Spawning environment shell (/bin/bash).
$ source /home/****/.venv/bin/activate
(pipenv) $
It displayed the additional newline as well as the source command being printed, although it did actually activate the venv.
I am not sure if my repo contains the latest pull requests, so I will pull and see if that changes anything.
@jessebraham
Well I don't know why you get two new lines after the Spawning statement. However, the printed source statement should be expected.
It seems like this issue is happening again using zsh 5.2 on mac, can anybody confirm if it is working?
pipenv==5.1.2
zsh==5.2
Thanks.
zsh 5.2 (x86_64-apple-darwin16.0)
pipenv, version 7.2.6
Not working.
I have no $HOME/.venv. Just using pipenv straightup.
I'm having the same issue with Bash. I added this to my .bashrc as a workaround:
if [[ $VIRTUAL_ENV ]]; then
PS1="$(echo $VIRTUAL_ENV | sed 's/.*\///') $PS1"
fi
this is a feature, not a bug. Many prompts (mine included) are virtualenv-aware, and will display virtualenv information automatically, so the (venv)
left side prompt is unnecessary and ugly.
pipenv shell -c
prepends the virtualenv name, if you prefer.
In windows prompt, no name is appended even when -c is used.
Most helpful comment
In windows prompt, no name is appended even when -c is used.