Using virtualenv with fish shell
suggest changeFish shell is friendlier, yet virtualenv and virtualenvwrapper are awkward there. virtualfish is the fish-native tool. It requires Fish 3.1 or newer.
- Install virtualfish for your user.
sudo piptargets the system interpreter and is rejected on many current systems:
python -m pip install --user virtualfish
- Install the loader from fish.
vf installwrites~/.config/fish/conf.d/virtualfish-loader.fish. The oldereval (python -m virtualfish)line, written with>intoconfig.fish, replaced the whole config file and is the 1.x setup:
vf install
exec fish
- Edit
fish_promptwithfunced fish_prompt. Add--editor nano(or another editor) if you do not want vim. Add:
if set -q VIRTUAL_ENV
echo -n -s (set_color -b blue white) "(" (basename "$VIRTUAL_ENV") ")" (set_color normal) " "
end
- Save changes using
funcsave
funcsave fish_prompt
- To create a new virtual environment use
vf new. Environments are stored in~/.virtualenvsby default:
vf new my_new_env
- If you want to create a new python3 environment, specify it via the
-pflag
vf new -p python3 my_new_env
- To switch between virtual environments use
vf deactivateandvf activate another_env
Official links:
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents