using powerline with virtualenvs

775 views
Skip to first unread message

Abraham Varricatt

unread,
May 5, 2017, 3:30:38 PM5/5/17
to powerline
Hello,

Is it possible to use powerline if you switch python virtualenvs often?

On my development system, I'm using the pyenv project to manage different Python versions and virtualenvs on top of that between different projects.

Here's what I did,

* created a new virtualenv based off python 3.5.3.
* activate the virtualenv
* pip install powerline-status

At this point, I add the 4 lines mentioned here,
https://powerline.readthedocs.io/en/master/usage/shell-prompts.html#bash-prompt
to my .bashrc file.

Starting a new terminal session produced an error message. Using pyenv, I set the virtualenv I installed powerline into as my global (default) virtualenv.

Then, when I started a new terminal session, I saw that my shell prompt looked different - success!

.. until I moved to another directory where I switched virtualenvs. Powerline broke. :(

My end goal is to use powerline with bash, tmux and vim. But I can't figure out how to keep it stable when switching virtualenvs. (Installing powerline in each of the virtualenvs is not a useable solution).


Anyone else facing this issue? Or are most of you non-Python developers?

Stumped,
Abraham V.

Nikolay Aleksandrovich Pavlov

unread,
May 5, 2017, 3:55:37 PM5/5/17
to Abraham Varricatt, powerline
2017-05-05 22:30 GMT+03:00 'Abraham Varricatt' via powerline
<powerlin...@googlegroups.com>:
I am mostly non-python, mainly developing powerline itself in Python
in addition to some relatively small scripts. You need to use either
powerline-daemon with either shell or zsh+zpython to switch
environments: this way powerline-daemon will load all necessary
modules once when reading configuration (it will do this when a
prompt/statusline (tmux) was requested, not when daemon was started)
and in any case it will stay always with its own environment variables
(environment variables from bash do get transferred to daemon, but
they do not go to `os.environ`, only used by segments).

>
> Stumped,
> Abraham V.
>
> --
> You received this message because you are subscribed to the Google Groups
> "powerline" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to powerline-supp...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Nikolay Aleksandrovich Pavlov

unread,
May 5, 2017, 3:58:10 PM5/5/17
to Abraham Varricatt, powerline
zpython is similar, including that in the current state `os.environ`
inherits environment variables from zsh once when Python interpreter
is initalized and never updates since then, despite interpreter
sharing one process with zsh.

Abraham Varricatt

unread,
May 5, 2017, 4:02:59 PM5/5/17
to powerline, abraham....@googlemail.com
Guess I'll try switching over to zsh as my default shell first and come back to powerline after that.

But it's good to know that I might be able to make this work, even with my setup! :)

Thanks,
Abraham V.

Nikolay Aleksandrovich Pavlov

unread,
May 5, 2017, 5:41:28 PM5/5/17
to Abraham Varricatt, powerline
2017-05-05 23:02 GMT+03:00 'Abraham Varricatt' via powerline
<powerlin...@googlegroups.com>:
> Guess I'll try switching over to zsh as my default shell first and come back
> to powerline after that.

zpython is not part of zsh, you will have to install (on some systems
compile and install) that separately. Just switching to zsh will not
help, you still need to start daemon from your zshrc or install
zpython (this one will be used automatically if available though).

One of the differences between zpython setup and daemon is that there
is one daemon per user for all shells and tmux instances while zpython
is one python interpreter per shell. This has its consequences: e.g.
after updating Python you will need to recompile zpython and restart
all shells, after updating powerline configuration if it failed to
reload automatically you need `powerline-reload-config` in all shells,
`powerline-reload` (or restart shell as `powerline-reload` is
officially experimental) after updating powerline itself in all shells
again. But only need to restart one daemon to reload everything
(powerline and config). Zpython would be slightly faster though.
Reply all
Reply to author
Forward
0 new messages